how to get to file in intranet using WebClient. simple ?!

V

Vasko Peter

Hi All,

I am breaking my head on one problem. I'd like to read a file that is on a
different machine in intranet. The tricky part is that I do not want to
allow an access for EVERYONE but want to minimise it for my machine only.

My Idea was to access the test.txt file as a user (MYUSERNAME) with my
password. I can access the file via file browser but if I do it in ASP.NET
Web application I get an access denied error.

The code is:

WebClient webClient = new WebClient();
string username = "MYMACHINENAME\\MYUSERNAME";
string password = "MYPASSWORD";
string domain = "MYDOMAIN";
webClient.Credentials = new
System.Net.NetworkCredential(username,password,domain);
binFile = webClient.DownloadData("\\\\FRIENDSCOMPUTER\\Test\\test.txt");
if (binFile.Length == 0) return null;
MemoryStream memStream = new MemoryStream(binFile);

I would be really thankful if you could point me to a solution.

Thanks a lot

p.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top