System Unauthorized Exception C# for file Info Class

Hi,

    I have to access a file from another system with in a network from c# web project. I have no problem in accessing the file when i run the project under default website with localhost. but i couldn't access the file when the project is made to use local iis web server, Is exists property of file info class is returning false and all other properties like isreadonly etc are returning SytemUnauthorized access. All the system in the network use windows 2008 server.  Can any one help me?
sumankrishnaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

deadlyDevCommented:
When running your asp.net application I assume you have configured it with a user account for anonymous access... This user account needs access to the remote file...
0
sumankrishnaAuthor Commented:
I am using iis6.0, i dont know where to check anonymous access credentials but in iis5.0 it used to be IUSR_ComputerName, I have given full control to the network service and IUSR in the security permissions of the file still i face the same issue.
0
sumankrishnaAuthor Commented:
FileInfo TragetFile = new FileInfo("\\dev01\c$\CMData.csv");
This is how i tried to access the file.
Even Directory.Exists("\\dev01\c$"); is showing false, while it is showing true when i ran the project with localhost.
           
0
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

deadlyDevCommented:
Go to computer management (Start -> Right Click on Computer -> Manage)...
On the left pane go to Services and Applications
Open the IIS node...
Locate your site...
Right Click -> Properties
Directory Security Tab
Click the edit button...

And you should see the user...

BTW i notice in your path you have the c$... this is an admin share. I would HIGHLY recommend setting up an independant share on the remote machine which the anonymous user has access to... If you give the anonymous user access on that share they will be able to access the entire c drive of the remote computer!
0
sumankrishnaAuthor Commented:
Actually I am using IIS7.0, Still I worked it on another system which has iis6.0 The anonymous User id is IUSR_DC01 I added this user in the security permissions of the file, still no luck.
0
deadlyDevCommented:
Does the user have permissions to the share... not the file... as I said earlier, you appear to be using an administrative share, in which case the IIS user will certainly not have access to the share (no matter what the permissions on the file are set to...)
0
sumankrishnaAuthor Commented:
Thanks for your quick replies
I have created a folder named access, shared it and given permission to everyone

string strFilePath = @"\\DEV01\Access\cmdata.csv";
and tried the above code. still didnt work.
0
strickddCommented:
make sure you specify the following tag in your web.config. It goes in the system.web section.
<identity impersonate="true" />

Open in new window

0
sumankrishnaAuthor Commented:
I have tried <identity impersonate="true" /> but didnt work
0
deadlyDevCommented:
I was just thinking... is the anonymous website user a domain user, or a user on the local machine? If not, create a domain user for your app to run on, and set it to run as that user...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sumankrishnaAuthor Commented:
It has worked thank you very much......
0
sumankrishnaAuthor Commented:
Thanks
0
deadlyDevCommented:
No problems mate... glad to help
0
sumankrishnaAuthor Commented:
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.