473,386 Members | 1,819 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.

File access question

Hello folks,

I am experiencing a rather strange problem. I have written a service
that attempts to open a file on a network share via a FileStream object.
When I try to open the file from my service, I get the "Access is
denied" error. However, if I try to open the file from a GUI
application, I can open the file without problem. I've tried using the
FileIOPermissions object to get around the error with no luck. Obviously
I am missing something very fundamental, the file is accessible to
'Everyone'. Does anybody know what I am doing wrong? Thank you,

Jason

Nov 16 '05 #1
4 2090
Hi Jason

Maybe it's rather a Windows than a .NET issue. The service may not have
enough privilegies to access the folder while your UI application (which
runs under the context of your user account) does...

Regards

Philipp

Hello folks,

I am experiencing a rather strange problem. I have written a service
that attempts to open a file on a network share via a FileStream object.
When I try to open the file from my service, I get the "Access is
denied" error. However, if I try to open the file from a GUI
application, I can open the file without problem. I've tried using the
FileIOPermissions object to get around the error with no luck. Obviously
I am missing something very fundamental, the file is accessible to
'Everyone'. Does anybody know what I am doing wrong? Thank you,

Jason

Nov 16 '05 #2
You are probably running into CAS issues. Fileshare is considered
LocalIntranet_Zone even if it is shared from your local computer. You
probably need to go to the .Net configuration tool and give that share a
special permissions. The tool is under aministrative tools, .Net
Framewwork 1.1 Configuration. Go to runtime security policy, Machine,
All_code and Add a child code group. Give it a name then on the choose a
condition tab select URL. In the bottom text field put the path to the
file share. I.E. file://F:/*. On the next tab select the permission set.
Leave it at FullTrust if you want all permissions. Now you should get no
errors accessing the file share.

Good Luck
Leon Lambert

Jason Hurder wrote:
Hello folks,

I am experiencing a rather strange problem. I have written a service
that attempts to open a file on a network share via a FileStream object.
When I try to open the file from my service, I get the "Access is
denied" error. However, if I try to open the file from a GUI
application, I can open the file without problem. I've tried using the
FileIOPermissions object to get around the error with no luck. Obviously
I am missing something very fundamental, the file is accessible to
'Everyone'. Does anybody know what I am doing wrong? Thank you,

Jason

Nov 16 '05 #3
"Access denied" errors are due to Windows permissions denials, not CAS
permission denials, so altering the CAS policy will not resolve this
problem.
"Leon Lambert" <la******@inil.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
You are probably running into CAS issues. Fileshare is considered
LocalIntranet_Zone even if it is shared from your local computer. You
probably need to go to the .Net configuration tool and give that share a
special permissions. The tool is under aministrative tools, .Net
Framewwork 1.1 Configuration. Go to runtime security policy, Machine,
All_code and Add a child code group. Give it a name then on the choose a
condition tab select URL. In the bottom text field put the path to the
file share. I.E. file://F:/*. On the next tab select the permission set.
Leave it at FullTrust if you want all permissions. Now you should get no
errors accessing the file share.

Good Luck
Leon Lambert

Jason Hurder wrote:
Hello folks,

I am experiencing a rather strange problem. I have written a service that
attempts to open a file on a network share via a FileStream object. When
I try to open the file from my service, I get the "Access is denied"
error. However, if I try to open the file from a GUI application, I can
open the file without problem. I've tried using the FileIOPermissions
object to get around the error with no luck. Obviously I am missing
something very fundamental, the file is accessible to 'Everyone'. Does
anybody know what I am doing wrong? Thank you,

Jason

Nov 16 '05 #4
Manipulating FileIOPermissions will not help resolve this exception since
"access denied" errors are caused by Windows permissions restrictions and
have nothing to do with .NET code access security.

A couple of questions:

1. If you launch the service using the same user credentials with which you
can open the file via the GUI application, can the service open the file?

2. Are you sure that "everyone" access is truly applied, or does this
reflect just the permissions on the share, as opposed to the Windows ACL on
the actual file? Access to a file via a share will be determined by the
intersection, not the union, of the permissions on the share and the file
itself.
"Jason Hurder" <jhurder@spam_me_not.fastpicsystems.com> wrote in message
news:u2**************@TK2MSFTNGP09.phx.gbl...
Hello folks,

I am experiencing a rather strange problem. I have written a service that
attempts to open a file on a network share via a FileStream object. When I
try to open the file from my service, I get the "Access is denied" error.
However, if I try to open the file from a GUI application, I can open the
file without problem. I've tried using the FileIOPermissions object to get
around the error with no luck. Obviously I am missing something very
fundamental, the file is accessible to 'Everyone'. Does anybody know what
I am doing wrong? Thank you,

Jason

Nov 16 '05 #5

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

Similar topics

4
by: Rene' Nielsen | last post by:
Context: Running Windows 2003 Server on an intranet. A web is configured with an anonymous access account that is a domain account that has been granted the desired access to a file on another...
5
by: Johnny Meredith | last post by:
I have seven huge fixed width text file that I need to import to Access. They contain headers, subtotals, etc. that are not needed. There is also some corrupt data that we know about and can...
1
by: gale | last post by:
I have an Access 2003 project. I need for users to be able to run a report and copy the report in Excel format to a web server. The problem is, they do not have write access to the web server. I...
18
by: Andre Laplume via AccessMonster.com | last post by:
I have inherited a bunch of dbs which are are shared among a small group in my dept. We typically use the dbs to write queries to extract data, usually dumping it into Excel. Most dbs originated...
6
by: Null Reference | last post by:
Anybody here who can explain or point me to a link ? I wish to create a blank MS Access DB file programmatically using C# . Thanks, nfs
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
6
by: Joe Bonavita | last post by:
What is the safest way to create a file on the server? I'm looking for something like: secureconnection(); // create the file disconnect();
9
by: CGW | last post by:
I asked the question yesterday, but know better how to ask it, today: I'm trying to use the File.Copy method to copy a file from a client to server (.Net web app under IIS ). It looks to me that...
12
by: dbuchanan | last post by:
Hello, (Is this the proper newsgroup?) === Background === I am building a solution with two projects. One project is my data access layer which contains my DataSet as an xsd file. The XSD...
2
by: Matt MacDonald | last post by:
Hi all, If this isn't the write forum for this question, I appologize, but it's kind of a mix of ASP.NET and IIS. Anyway, my question is this. If an ASP.NET site is writing to a file, does the...
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: 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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.