PassFTP Client

FTP Library

Support

Contact



Sample Coding

class FtpConnect { public FtpWebRequest fRequest = null; NetworkCredential netCred = null; public FtpWebResponse fResponse = null; public string ftpHname,ftpUname,ftpUpass,setRemoteCurPath; public string transMode = "Passive"; public string transType = "Binary"; public void FtpInit() { fRequest = (FtpWebRequest)WebRequest.Create("ftp://" + ftpHname + setRemoteCurPath); netCred = new NetworkCredential(ftpUname, ftpUpass); fRequest.Credentials = netCred; fRequest.KeepAlive = false; if (transType == "Binary") fRequest.UseBinary = true; else if (transType == "ASCII") fRequest.UseBinary = false; else if (transType == "Auto") { if (fRequest.UseBinary == true) fRequest.UseBinary = false; else fRequest.UseBinary = true; } if (transMode == "Active") fRequest.UsePassive = false; else if (transMode == "Passive") fRequest.UsePassive = true; } public void FtpDirecotryList(string DirecoryName) { setRemoteCurPath = DirecoryName; FtpInit(); fRequest.Method = WebRequestMethods.Ftp.ListDirectoryDetails; } public void FtpGetFileSize(string FileName) { setRemoteCurPath = FileName; FtpInit(); fRequest.Method = WebRequestMethods.Ftp.GetFileSize; } public void FtpDownLoadFile(string FileName) { setRemoteCurPath = FileName; FtpInit(); fRequest.Method = WebRequestMethods.Ftp.DownloadFile; } public void FtpRenameFile(string FileName, string RenFileTo) { setRemoteCurPath = FileName; FtpInit(); fRequest.Method = WebRequestMethods.Ftp.Rename; fRequest.RenameTo =RenFileTo; } public void FtpDeleteFile(string FileName) { setRemoteCurPath = FileName; FtpInit(); fRequest.Method = WebRequestMethods.Ftp.DeleteFile; } public void FtpRemoveDirectory(string DirectoryName) { setRemoteCurPath = DirectoryName; FtpInit(); fRequest.Method = WebRequestMethods.Ftp.RemoveDirectory; } public void FtpMakeDirectory(string DirectoryName) { setRemoteCurPath = DirectoryName; FtpInit(); fRequest.Method = WebRequestMethods.Ftp.MakeDirectory; } public void FtpUpLoadFile(string FileName,long FileSize) { setRemoteCurPath = FileName; FtpInit(); fRequest.ContentLength = FileSize; fRequest.Method = WebRequestMethods.Ftp.UploadFile; } }