You are right! Thanks!

> -----Original Message-----
> From: dotnet discussion [mailto:[EMAIL PROTECTED]] On Behalf
Of
> Simon Fell
> Sent: Thursday, April 25, 2002 1:29 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [DOTNET] Bug in FileStream?
>
> The top piece of code is trying to get read/write access to the file,
> whilst the bottom one is read only, try changing it to
>
> FileStream fs = new FileStream("\\comp with space\inbox\readme.txt",
> FileMode.Open, FileAccess.Read );
>
> Cheers
> Simon
> www.pocketsoap.com
>
> On Thu, 25 Apr 2002 01:40:47 -0400, in dotnet you wrote:
>
> >I am trying to open a file on a UNC path. The computer name in the
UNC
> >path contains spaces. The FileStream constructor throws a "Network
> >access denied" IOException.
> >
> >try
> >{
> >        FileStream fs = new FileStream("\\comp with
> >space\inbox\readme.txt", FileMode.Open);
> >}
> >catch(IOException ex)
> >{
> >        Console.WriteLine(ex.Message); // outputs "Network access is
> >denied."
> >}
> >
> >However, if I use the FileInfo.OpenRead() to open the file, I can
> >successfully get a FileStream!
> >
> >FileInfo fi = new FileInfo("\\comp with space\inbox\readme.txt");
> >Using(FileStream fs = fi.OpenRead())
> >{
> >        byte [] content = new byte[fs.Length];
> >        fs.Read(content, 0, (int)fs.Length);
> >}
> >
> >Anybody faced this problem before?
> >
> >Thanks
> >
> >Deepak
> >
> >You can read messages from the DOTNET archive, unsubscribe from
DOTNET,
> or
> >subscribe to other DevelopMentor lists at http://discuss.develop.com.
>
> You can read messages from the DOTNET archive, unsubscribe from
DOTNET, or
> subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to