.Net 2.0 C# FileStream question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jason Huang

    .Net 2.0 C# FileStream question

    Hi,

    In my C# web application I have a code as:
    FileStream fs = new FileStream(@"c: \temp\AAA.txt" , FileMode.OpenOr Create,
    FileAccess.Read Write);
    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


  • Marc Gravell

    #2
    Re: .Net 2.0 C# FileStream question

    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


    Comment

    Working...