New Message on dotNET User Group Hyd

reading a remote file

Reply
  Reply to Sender   Recommend Message 2 in Discussion
From: Deeps2808

Hi all,
No replies received frens.....
Nways I got the solution so thought to post it , incase anyone needs it.
When I tried to read the same remote file using a console or windows application using C#, it successfully read it. This was because Windows or console application when tries to read a file from remote computer it logson to that comp using ur Windowns username and pwd.
But in case of ASP.Net its different.....when a ASP.Net C# code tries to logon to the remote computer, it uses its own account and not ur windowns account . This account could be ASPNET or IIS_WPG......
So to access a remote file using ASP.Net that has to be done by giving a URI instead of just filepath

For opening a file using URI, we have a class in Net called as WebClient.

Here's the code snippet

WebClient myclient= new WebClient();
Stream st=mycl.OpenRead(@"http://machine-name/filepath");
StreamReader sr=new StreamReader(st)
...

Then startreading the file using the streamReader.


Thanks,
Deeps

View other groups in this category.


Also on MSN:
Start Chatting | Listen to Music | House & Home | Try Online Dating | Daily Horoscopes

To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings.

Need help? If you've forgotten your password, please go to Passport Member Services.
For other questions or feedback, go to our Contact Us page.

If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list.
Remove my e-mail address from dotNET User Group Hyd.

Reply via email to