Filestream/StreamWriter in ASP.NET
Messages   Related Types
This message was discovered on ASPFriends.com 'ngfx-io' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

John Watson
-- Moved from [aspngstart] to [ngfx-io] by Marcie Jones <Click here to reveal e-mail address> --

hi,

I'm trying to write to a file using ASP.NET. I use this code:

Dim x As New FileStream("C:\FileName.txt", FileMode.Append)
Dim y As New StreamWriter(x)
y.WriteLine(TheText)

When I run the program I always get this message:

"System.IO.IOException: The process cannot access the file "C:\FileName.txt"
because it is being used by another process"

Anyone know why this is? Even if I change FileName to a file that doesn't
exist I get this message.

Reply to this message...
 
    
Jason Hall
I got this before, trying to write out image files to a directory, ended up
being a security issue.

[Original message clipped]

_________________________________________________________________
Join the world’s largest e-mail service with MSN Hotmail.
http://www.hotmail.com

Reply to this message...
 
    
John Watson
Jason, how did you fix the problem? I get this error in both ASP.NET and
VB.NET GUI projects.

----- Original Message -----
From: "Jason Hall" <Click here to reveal e-mail address>
To: "ngfx-io" <Click here to reveal e-mail address>
Sent: Monday, May 06, 2002 7:20 PM
Subject: [ngfx-io] Re: Filestream/StreamWriter in ASP.NET

> I got this before, trying to write out image files to a directory, ended
up
[Original message clipped]

Reply to this message...
 
    
Mitch Denny (VIP)
John,

It could be permissions, especially with ASP.NET, but also
check to see what processes might have a handle on that
file, something unexpected might be happening, for example
anti-virus software might be locking the file.

Head on over to http://www.sysinternals.com and download
their free Process Explorer utility, its pretty easy to
figure out how to use it.

----------------------------------------
- Mitch Denny
- Click here to reveal e-mail address
- +61 (414) 610-141
-

-----Original Message-----
From: John Watson [mailto:Click here to reveal e-mail address]
Sent: Tuesday, 7 May 2002 02:24
To: ngfx-io
Subject: [ngfx-io] Filestream/StreamWriter in ASP.NET

-- Moved from [aspngstart] to [ngfx-io] by Marcie Jones
<Click here to reveal e-mail address> --

hi,

I'm trying to write to a file using ASP.NET. I use this code:

Dim x As New FileStream("C:\FileName.txt", FileMode.Append)
Dim y As New StreamWriter(x)
y.WriteLine(TheText)

When I run the program I always get this message:

"System.IO.IOException: The process cannot access the file
"C:\FileName.txt" because it is being used by another process"

Anyone know why this is? Even if I change FileName to a file that
doesn't exist I get this message.

| [ngfx-io] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/ngfx-io.asp = JOIN/QUIT

Reply to this message...
 
    
Vladimir Chernetsky
Use following syntax:

StreamWriter sw = new StreamWriter("c:\filename.txt",...);
sw.WriteLine(...)

-----Original Message-----
From: John Watson [mailto:Click here to reveal e-mail address]
Sent: Monday, May 06, 2002 8:24 PM
To: ngfx-io
Subject: [ngfx-io] Filestream/StreamWriter in ASP.NET

-- Moved from [aspngstart] to [ngfx-io] by Marcie Jones
<Click here to reveal e-mail address> --

hi,

I'm trying to write to a file using ASP.NET. I use this code:

Dim x As New FileStream("C:\FileName.txt", FileMode.Append)
Dim y As New StreamWriter(x)
y.WriteLine(TheText)

When I run the program I always get this message:

"System.IO.IOException: The process cannot access the file "C:\FileName.txt"
because it is being used by another process"

Anyone know why this is? Even if I change FileName to a file that doesn't
exist I get this message.

| [ngfx-io] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/ngfx-io.asp = JOIN/QUIT
Reply to this message...
 
    
Jason Hall
In that case it's not the same, I only got it in ASP.NET.

Try using the constructor of filestream that takes

filestream(string(path),filemode(append etc...),access(read, write etc.))

I do know that append mode only allows write access, maybe it's confused
because of some default access mode or something. I will mess with it some
when I get to work.

[Original message clipped]

_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com

Reply to this message...
 
 
System.IO.FileMode
System.IO.FileStream
System.IO.IOException
System.IO.StreamWriter




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com