using System.Net;
public void ftpfile(string ftpfilepath, string inputfilepath)
{
string ftphost = "122.22.1.1"; // destination IP address
string ftpfullpath = "ftp://" + ftphost + ftpfilepath;
FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath);
ftp.Credentials = new NetworkCredential("userid", "password");
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();
}
Thursday, December 2, 2010
Send file on FTP using .net
To send a file over FTP using asp.net / c#.net / vb.net :
Share This!
Subscribe to:
Post Comments (Atom)
2 comments:
thanks for providing solution. keep it up.
this solution made me yours crazy fan...
Post a Comment