public void FTPFileUpload(string ftpfilepath, string inputfilepath) { string ftphost = "208.91.199.15"; // your server name or localhost string ftpfullpath = "ftp://" + ftphost + ftpfilepath; FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath); ftp.Credentials = new NetworkCredential("tinu", "pass@123"); //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(); } private void SaveOnLocal(FileUpload Img) { string _videopath = Img.FileName; _videopath = Environment.GetEnvironmentVariable("temp") + "\\" + _videopath;// System.IO.Path.GetFullPath(video.PostedFile.FileName); FileIOPermission ioPerm = new FileIOPermission(FileIOPermissionAccess.Write, _videopath); ioPerm.Demand(); Img.SaveAs(_videopath); FTPFileUpload("/Video/", _videopath); // System.IO.File.Delete(_videopath); }public void FTPFileUpload(string ftpfilepath, string inputfilepath) { string ftphost = "200.45.459.49"; // your server name or localhost string ftpfullpath = "ftp://" + ftphost + ftpfilepath; FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath); ftp.Credentials = new NetworkCredential("Myusername", "MyPasswd"); //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(); } private void SaveOnLocal(FileUpload Img) { string _videopath = Img.FileName; _videopath = Environment.GetEnvironmentVariable("temp") + "\\" + _videopath;// System.IO.Path.GetFullPath(video.PostedFile.FileName); FileIOPermission ioPerm = new FileIOPermission(FileIOPermissionAccess.Write, _videopath); ioPerm.Demand(); Img.SaveAs(_videopath); FTPFileUpload("/Video/", _videopath); // System.IO.File.Delete(_videopath); }
FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath);
WebRequest ftp = WebRequest.Create(ftpfullpath + FileName);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)