Why am I getting a

  • Thread starter Thread starter Frank Rizzo
  • Start date Start date
F

Frank Rizzo

I try to open a file using this line:

FileStream oStream = File.Open(FileName, FileMode.Open,
FileAccess.Write, FileShare.None);

When I try to open a file "\\CON-GELBR\TRAFFIC_LOAD\01012605.trf", I am
getting the following error:

System.UnauthorizedAccessException: Access to the path
"\\CON-GELBR\TRAFFIC_LOAD\01012605.trf" is denied.

I can open the file using Notepad. Does the File.Open method not work
with UNC paths? Or am I missing something stupid?

If File.Open does not work with UNC paths, what's my alternative?
I am doing this from a WinForm exe.

Thanks
 
Where is your .NET .exe file stored? On a local drive, or on a shared
network drive?

No, I've never tried using UNC paths in File.Open, but I do know for a
fact that .NET executables loaded from network shares have a lower
trust level than the same application running off your local drive.
(Code access security, and all that.)

Perhaps this is the problem?
 
This is probably a security issue with .Net. Try making your app fully
trusted.

Chris
 
Thanks guys. I figured out the issue. The application was running from
local drive and the share was on a local drive as well. However, I
didn't give the share Modify rights. I kind of assumed that because I
am an admin on my box, I would automatically have rights to everything
on my machine (including shares), but that was not the case.

Regards
 
Back
Top