Hi,
i am developing the tool that i want to transfer the file
from local to remote. when i run the aplicatioon it shows some error.
the below code i m using..
//string filename = "c:\\test.xls";
FileInfo fileInf = new FileInfo("c:\\test.xls");
string uri = "ftp://" + "Ipaddress" + "/" + fileInf.Name;
FtpWebRequest reqFTP = (FtpWebRequest)
FtpWebRequest.Create(uri);
//HttpWebRequest reqFTP = (HttpWebRequest)
HttpWebRequest.Create(uri);
reqFTP.Credentials = new NetworkCredential("username",
"password","domain");
reqFTP.KeepAlive = false;
reqFTP.Proxy = null;
reqFTP.Method = WebRequestMethods.Ftp.UploadFile;
//reqFTP.Method = WebRequestMethods.Http.Post;
//reqFTP.uUseBinary = true;
reqFTP.ContentLength = fileInf.Length;
int buffLength = 2048;
byte[] buff = new byte[buffLength];
int contentLen;
FileStream fs = fileInf.OpenRead();
// Stream to which the file to be upload is written
Stream strm = reqFTP.GetRequestStream();
// Read from the file stream 2kb at a time
contentLen = fs.Read(buff, 0, buffLength);
// Till Stream content ends
while (contentLen != 0)
{
// Write Content from the file stream to the FTP
Upload
// Stream
strm.Write(buff, 0, contentLen);
contentLen = fs.Read(buff, 0, buffLength);
}
// Close the file stream and the Request Stream
strm.Close();
fs.Close();
please any one can help me to finish this task
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web
Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://cm.megasolutions.net/forums/default.aspx
-~----------~----~----~----~------~----~------~--~---