C#, Asp.net Uploading files to file server...

Posted by Imcl on Stack Overflow See other posts from Stack Overflow or by Imcl
Published on 2010-03-15T07:15:57Z Indexed on 2010/03/15 7:19 UTC
Read the original article Hit count: 502

Filed under:
|
|
|

Using the link below, I wrote a code for my application. I am not able to get it right though, Please refer the link and help me ot with it...

http://stackoverflow.com/questions/263518/c-uploading-files-to-file-server

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

        arrReturn = client.UploadFile(addy, filePath);
        Console.WriteLine(arrReturn.ToString());
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message);
    }

}

I also used:- File.Copy(filePath, "\\192.168.1.3\upload\");

The following line doesnt execute...

byte[] arrReturn = client.UploadFile(addy, filePath);

tried changing it to:-

byte[] arrReturn = client.UploadFile("\\192.168.1.3\upload\", filePath);

IT still doesnt work...Any solution to it??

I basically want to transfer a file from the client to the file storage server without actually loggin into the server so that the client cannot access the storage location on the server directly...

© Stack Overflow or respective owner

Related posts about c#

Related posts about byte