.NETGURU
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




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification