Shilpa

Shilpa

  • NA
  • 5
  • 0

ASP.NET file transfer from local machine to another machine

Mar 17 2010 4:44 AM

I basically want to transfer a file from the client machine to the file storage server without actual login to the server so that the client cannot access the storage location on the server directly. I can do this only if i manually login to the storage server through windows login. I dont want to do that. This is a Web-Based Application.

Is there any other method to perform the file transfer?


The following is my code:-
protected void Button1_Click(object sender, EventArgs e)  
{  
 
    filePath = FileUpload1.FileName;      
    try  
    {  
        WebClient client = new WebClient();  
 
        NetworkCredential nc = new NetworkCredential(uName, password);  
 
        Uri addy = new Uri("\\\\192.168.1.3\\upload\\");  
        client.Credentials = nc;  
        byte[] arrReturn = client.UploadFile(addy, filePath);  
 
        Console.WriteLine(arrReturn.ToString());  
    }  
    catch (Exception ex)  
    {  
        Console.WriteLine(ex.Message);  
    }  
 
}  

The following line doesn't execute...
byte[] arrReturn = client.UploadFile(addy, filePath);  

This is the error I get:

An exception occurred during a WebClient request

Answers (3)