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

Discussion in 'ASP .Net Security' started by Vasko Peter, Aug 13, 2004.

  1. Vasko Peter

    Vasko Peter Guest

    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
    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

    Vasko Peter, Aug 13, 2004
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.