.Net 2.0 C# FileStream question

  • Thread starter Thread starter Jason Huang
  • Start date Start date
J

Jason Huang

Hi,

In my C# web application I have a code as:
FileStream fs = new FileStream(@"c:\temp\AAA.txt" , FileMode.OpenOrCreate,
FileAccess.ReadWrite);
When I execute the application, it gave me an error saying refusing access
to that file.
I have the AAA.txt on client's PC's c:\temp\AAA.txt, and it's not readonly.
What could I have done wrong?
Thanks for help.


Jason
 
In my C# web application I have a code as:
FileStream fs = new FileStream(@"c:\temp\AAA.txt" , FileMode.OpenOrCreate,
FileAccess.ReadWrite);
When I execute the application, it gave me an error saying refusing access
to that file.
I have the AAA.txt on client's PC's c:\temp\AAA.txt, and it's not readonly.
What could I have done wrong?
Thanks for help.

It's a web application, which means it will be running as a different
user (the exact user will depend on configuration).

Find out which user the web app is running as, and make sure that user
has permission for c:\temp.

I assume that when you say "client's PC" you mean the client's web
server - not the PC running a client *browser*, by the way...

Jon
 
Is the file still open elsewhere? If code has generated this file
moments before, this is entirely possible (since you aren't visibly
using "using" etc for the read, I'm guessing you might not have done
so for the write).

One way to tell by what: obtain "Process Explorer" (free download from
technet) and search for the file handle.

Also: does the specific account in question have access?

Marc
 
Back
Top