Is there any other method to perform the file transfer?
The following is my code:-
Java
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...
Code
byte[] arrReturn = client.UploadFile(addy, filePath);This is the error I get:
An exception occurred during a WebClient request

Amit ChoudharyRank #145 · 15.8K reputationPosted Mar 17, 2010, 2:44 AM EDT
Try below code for uploading file on ftp server with user credentials:
public void ftpfile(string ftpfilepath, string inputfilepath) { string ftphost = "192.168.1.3"; //here correct hostname or IP of the ftp server to be given string ftpfullpath = "ftp://" + ftphost + ftpfilepath; FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath); ftp.Credentials = new NetworkCredential("userid", "password"); //userid and password for the ftp server to given ftp.KeepAlive = true; ftp.UseBinary = true; ftp.Method = WebRequestMethods.Ftp.UploadFile; FileStream fs = File.OpenRead(inputfilepath); byte[] buffer = new byte[fs.Length]; fs.Read(buffer, 0, buffer.Length); fs.Close(); Stream ftpstream = ftp.GetRequestStream(); ftpstream.Write(buffer, 0, buffer.Length); ftpstream.Close(); }Shilpa5 reputationPosted Mar 18, 2010, 2:28 AM EDT
I used your code. Execution stops at the following line :-
Stream ftpstream = ftp.GetRequestStream();
and this is the error that is displayed:-
"Unable to connect to the remote server"
Shilpa5 reputationPosted Mar 18, 2010, 4:16 AM EDT