By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,848 Members | 1,598 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,848 IT Pros & Developers. It's quick & easy.

mscorlib: Access to the path is denied.

P: n/a
I'm tring to open a file using FileStream:
dim myFile As New FileStream(myPath, FileMode.Open)

It works on every file on FAT32 HDD fine.
But when I try to open a several files on NTFS drive I get this message:
'Access to the path " ... " is denied.'

Some files on NTFS are working fine.
I checked the permitions and I do have the permition to do everything with
this file or folder as I'm the administrator of this PC.

What am I doing wrong?
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
If you are opening it for reading only, you should use the overloaded
constructor that receives a System.IO.FileShare param and pass it
System.IO.FileShare.Read, because by default is open for write and if 2
processes do the same, one of them denies access to the other:

public FileStream ( System.String path , System.IO.FileMode mode ,
System.IO.FileAccess access , System.IO.FileShare share )
--

Carlos J. Quintero

The MZ-Tools all-in-one add-in, now for .NET: http://www.mztools.com
"Alex Levi" <Al******@discussions.microsoft.com> escribió en el mensaje
news:C8**********************************@microsof t.com...
I'm tring to open a file using FileStream:
dim myFile As New FileStream(myPath, FileMode.Open)

It works on every file on FAT32 HDD fine.
But when I try to open a several files on NTFS drive I get this message:
'Access to the path " ... " is denied.'

Some files on NTFS are working fine.
I checked the permitions and I do have the permition to do everything with
this file or folder as I'm the administrator of this PC.

What am I doing wrong?

Nov 21 '05 #2

P: n/a
Thanks it helped !

"Carlos J. Quintero [.NET MVP]" wrote:
If you are opening it for reading only, you should use the overloaded
constructor that receives a System.IO.FileShare param and pass it
System.IO.FileShare.Read, because by default is open for write and if 2
processes do the same, one of them denies access to the other:

public FileStream ( System.String path , System.IO.FileMode mode ,
System.IO.FileAccess access , System.IO.FileShare share )
--

Carlos J. Quintero

The MZ-Tools all-in-one add-in, now for .NET: http://www.mztools.com
"Alex Levi" <Al******@discussions.microsoft.com> escribió en el mensaje
news:C8**********************************@microsof t.com...
I'm tring to open a file using FileStream:
dim myFile As New FileStream(myPath, FileMode.Open)

It works on every file on FAT32 HDD fine.
But when I try to open a several files on NTFS drive I get this message:
'Access to the path " ... " is denied.'

Some files on NTFS are working fine.
I checked the permitions and I do have the permition to do everything with
this file or folder as I'm the administrator of this PC.

What am I doing wrong?


Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.