473,386 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Why am I getting a

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
Nov 16 '05 #1
3 1537
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?

Nov 16 '05 #2
This is probably a security issue with .Net. Try making your app fully
trusted.

Chris
"Frank Rizzo" <no**@none.com> wrote in message
news:uh**************@TK2MSFTNGP12.phx.gbl...
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

Nov 16 '05 #3
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

Chris, Master of All Things Insignificant wrote:
This is probably a security issue with .Net. Try making your app fully
trusted.

Chris
"Frank Rizzo" <no**@none.com> wrote in message
news:uh**************@TK2MSFTNGP12.phx.gbl...
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.


Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Eyal | last post by:
Hey, I would appriciate if anyone can help on this one: I have a java object/inteface having a method with a boolean parameter. As I'm trying to call this method from a javascript it fails on...
5
by: Francis Bell | last post by:
I just found that my fin stream is not getting passed to my readInASpinnerbait function. Here's what I have: string readInFirstChars(ifstream &fin) { char first; string print; while...
8
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported...
0
by: Si | last post by:
I'm writing an HttpModule to intecept web method calls and retrieve custom authentication information from their SOAP headers. I have the httpModules tag in web.config and that appears to be...
3
by: dei3cmix | last post by:
Hey, I am having a problem with a program I am working on. Basically, the first part of the program gets input from a file using cin.getline. Then the second part, (still in the same main as the...
32
by: paul | last post by:
HI! I keep on getting this error and I have tried different things but I am not sure how to send the expiring date. The error that I am getting in Firefox 1.5 is "Error: expires.toGMTString is...
2
by: MSK | last post by:
Hi, Continued to my earlier post regaring "Breakpoints are not getting hit" , I have comeup with more input this time.. Kindly give me some idea. I am a newbie to .NET, recently I installed...
4
by: R.Manikandan | last post by:
Hi In my code, one string variable is subjected to contain more amount of characters. If it cross certain limit, the string content in the varabile is automatically getting truncated and i am...
4
by: imaloner | last post by:
I am posting two threads because I have two different problems, but both have the same background information. Common Background Information: I am trying to rebuild code for a working,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.