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
    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.
     
    Vasko Peter, Aug 13, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. buran
    Replies:
    0
    Views:
    387
    buran
    Sep 13, 2003
  2. natzol
    Replies:
    0
    Views:
    499
    natzol
    Dec 1, 2006
  3. =?Utf-8?B?c3dlZXR5?=

    Download a File using WebClient class

    =?Utf-8?B?c3dlZXR5?=, Jul 31, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    499
    =?Utf-8?B?c3dlZXR5?=
    Jul 31, 2007
  4. buran
    Replies:
    0
    Views:
    140
    buran
    Sep 13, 2003
  5. Kam
    Replies:
    4
    Views:
    149
    Bob Barrows [MVP]
    Sep 4, 2006
Loading...

Share This Page