473,396 Members | 1,963 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,396 software developers and data experts.

How to read a file from a different drive on the same machine C# windows based application

The file I would like to access in located in C drive and the
application which reads the file is located in E drive. When it trys to
read the file, it generates an error

Error: Request for the permission of type
System.Security.Permissions.FileIOPermission, mscorlib,
Version=1.0.5000.0, Cu
lture=neutral, PublicKeyToken=b77a5c561934e089 failed.

How to read the file?

Thanks

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #1
3 1779
this has nothing to do with the drive letter. your "read" would fail
regardless of the drive. You do not have permission to read.

Is this, perhaps, an ASP.Net application? If so, your app is probably
running using Network Service permissions, which gives you no access to the
file system. You'll need to either impersonate the user accessing your
site, or impersonate a "service account" (which is an account that you set
up just for your app to use). Check out the impersonate tag in the
web.config file.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"TaeHo Yoo" <yo******@yahoo.com> wrote in message
news:uc**************@TK2MSFTNGP09.phx.gbl...
The file I would like to access in located in C drive and the
application which reads the file is located in E drive. When it trys to
read the file, it generates an error

Error: Request for the permission of type
System.Security.Permissions.FileIOPermission, mscorlib,
Version=1.0.5000.0, Cu
lture=neutral, PublicKeyToken=b77a5c561934e089 failed.

How to read the file?

Thanks

*** Sent via Developersdex http://www.developersdex.com ***

Nov 17 '05 #2
Thanks Nick,

But this is a windows based application and when I put the application
in C drive where the file ,which this application reads, resides then it
works find but when I move it to other drives other than C then I get
the error.

Thanks

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #3
Your E drive is a mapped network share, right? You have to run caspol.exe to
change the CAS policy to fully trust the share.
Check MSDN for details on "Code Access Security" and "caspol".

Willy.
"TaeHo Yoo" <yo******@yahoo.com> wrote in message
news:uc**************@TK2MSFTNGP09.phx.gbl...
The file I would like to access in located in C drive and the
application which reads the file is located in E drive. When it trys to
read the file, it generates an error

Error: Request for the permission of type
System.Security.Permissions.FileIOPermission, mscorlib,
Version=1.0.5000.0, Cu
lture=neutral, PublicKeyToken=b77a5c561934e089 failed.

How to read the file?

Thanks

*** Sent via Developersdex http://www.developersdex.com ***

Nov 17 '05 #4

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

Similar topics

2
by: Jim Richards | last post by:
I have been told by a local PC club technician that 98SE cannot read NTFS drives in a network. Is this true? TIA, Jim.
1
by: TaeHo Yoo | last post by:
The file I would like to access in located in C drive and the application which reads the file is located in E drive. When it trys to read the file, it generates an error Error: Request for the...
3
by: Michael Bøcker-Larsen | last post by:
Hi I'v been stuck on this problem for ages now. I have found that I'm not the only one with this problem, by looking through the different newsgroups. Hope you can help me! I know there is a...
2
by: Michal Valent | last post by:
Hello, if I try to read a file on the mapped network drive, this error apears: Logon failure: unknown user name or bad password. How to set up permissions for IUSR_MACHINENAME on the mapped...
4
by: who be dat? | last post by:
I feel stupid for asking this but I can't figure this out. I've got some text files I want my website to read. The text files are located in a subdirectory of my application. Physically, the...
4
by: tshad | last post by:
At work we are setting up a new web site and had a problem with running a page when using URL: \\phoenix\cdrive\inetpub\wwwroot\hrworkshop\index.aspx It would start up notepad to edit the...
2
by: Gerhard | last post by:
I have a .net application that I want to run in a DMZ, with the SQL Server and file system behind another firewall. Is there a secure way to get to files from my application, or would it be better...
12
by: benjamin.krulewitch | last post by:
I'm debugging an issue with a C program that causes the computer to crash, and I'm attempting to log information immediately before the crash occurs. I us my BKprintLog function (see below) to...
2
by: Bill Fallon | last post by:
I have a VS2005 VB.Net windows form application deployed to a share drive. The windows explorer security permissions for this application (.exe) file is set for Everyone with List Folder/Read Data...
6
by: Scott Gravenhorst | last post by:
Windows XP SP3 My application is set to open a SaveFile dialog when an exit is requested. When I click the app's close button, the save dialog opens, but when I click to change the folder, the...
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: 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
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...
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.