473,782 Members | 2,487 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
FileIOPermissio ns 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 2112
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
FileIOPermissio ns 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_Z one 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
FileIOPermissio ns 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******** ********@TK2MSF TNGP15.phx.gbl. ..
You are probably running into CAS issues. Fileshare is considered
LocalIntranet_Z one 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 FileIOPermissio ns
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 FileIOPermissio ns 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_m e_not.fastpicsy stems.com> wrote in message
news:u2******** ******@TK2MSFTN GP09.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 FileIOPermissio ns 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
4698
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 server in the domain. An asp page in the web attempts to open (or any other access) the remote file and fails. Auditing is enabled on the remote system and for the file in question but no access denied records are being recorded.
5
11597
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 correct once the data is in Access (or during the import process itself). Furthermore, the text files are poorly set up, such that some records may be "shifted" over a few characters, and therefore the fixed width nature of the file is corrupted. ...
1
2958
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 tried to have the Excel file saved to a public directory and then have a bat file run (from Call Shell in Access) to copy it to the secure directory, but to no avail. The problem is, the bat file, although located on a server, is executed from the...
18
7346
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 in MsAccess 97 or prior and have been converted to 2003. On occassion user 1 will open a db. When user 2 opens the db it will not let user 2 modify macros and what not. I can understand this and realize we could split the db; it is not worth ...
6
13457
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
3940
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. It is almost like it is trying to implement it's own COM interfaces... below is the header, and a link to the dll+code: Zip file with header, example, and DLL:...
6
1170
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
2416
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 when I give a path like @"C:\holdfiles\myfile.txt" it looks on the server C drive. How do I pull from the client? Do I need a different class and/or method? Filestream? -- Thanks,
12
13438
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 file was built by draging tables from the Data Sources pane. Auto-generated code created the files associated wtih the XSD file (xss,
2
2025
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 file get written as soon as the request is processed or once the IIS Worker Process queues it up? For example: Users 1, 2, and 3 all hit the page that called the file write at the same time. Am I left to deal with a file access violation...
0
9639
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9479
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10311
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8967
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4043
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3639
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2874
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.