代码如下:
代码
//
建立目录
FtpWebRequest Request = (FtpWebRequest)WebRequest.Create( " ftp://113.107.160.135:2121/vadmin.uuu9.com/aaa " );
Request.Credentials = new NetworkCredential( " wanglei " , @" }}XnJXt4a\7datr " );
Request.Method = WebRequestMethods.Ftp.MakeDirectory;
Request.Timeout = ( 60000 * 1 ); // 60000 * 1,表示1分鐘
FtpWebResponse Response = (FtpWebResponse)Request.GetResponse();
Response.Close();
// 修改檔案名稱
FtpWebRequest Request = (FtpWebRequest)WebRequest.Create( " ftp://111.11.11.11:1234/C/puma/ssa.txt " );
Request.Credentials = new NetworkCredential( " id " , " pwd " );
Request.Method = WebRequestMethods.Ftp.Rename;
Request.Timeout = ( 60000 * 1 ); // 60000 * 1,表示1分鐘
Request.RenameTo = " NewName.txt " ;
FtpWebResponse Response = (FtpWebResponse)Request.GetResponse();
Response.Close();
// 修改目錄名稱
FtpWebRequest Request = (FtpWebRequest)WebRequest.Create( " ftp://111.11.11.11:1234/C/puma/test " );
Request.Credentials = new NetworkCredential( " id " , " pwd " );
Request.Method = WebRequestMethods.Ftp.Rename;
Request.Timeout = ( 60000 * 1 ); // 60000 * 1,表示1分鐘
Request.RenameTo = " test2 " ;
FtpWebResponse Response = (FtpWebResponse)Request.GetResponse();
Response.Close();
// 移除檔案
FtpWebRequest Request = (FtpWebRequest)WebRequest.Create( " ftp://111.11.11.11:1234/C/puma/NewName.txt " );
Request.Credentials = new NetworkCredential( " id " , " pwd " );
Request.Method = WebRequestMethods.Ftp.DeleteFile;
Request.Timeout = ( 60000 * 1 ); // 60000 * 1,表示1分鐘
FtpWebResponse Response = (FtpWebResponse)Request.GetResponse();
Response.Close();
// 移除目錄
FtpWebRequest Request = (FtpWebRequest)WebRequest.Create( " ftp://111.11.11.11:1234/C/puma/test2 " );
Request.Credentials = new NetworkCredential( " id " , " pwd " );
Request.Method = WebRequestMethods.Ftp.RemoveDirectory;
Request.Timeout = ( 60000 * 1 ); // 60000 * 1,表示1分鐘
FtpWebResponse Response = (FtpWebResponse)Request.GetResponse();
Response.Close();
FtpWebRequest Request = (FtpWebRequest)WebRequest.Create( " ftp://113.107.160.135:2121/vadmin.uuu9.com/aaa " );
Request.Credentials = new NetworkCredential( " wanglei " , @" }}XnJXt4a\7datr " );
Request.Method = WebRequestMethods.Ftp.MakeDirectory;
Request.Timeout = ( 60000 * 1 ); // 60000 * 1,表示1分鐘
FtpWebResponse Response = (FtpWebResponse)Request.GetResponse();
Response.Close();
// 修改檔案名稱
FtpWebRequest Request = (FtpWebRequest)WebRequest.Create( " ftp://111.11.11.11:1234/C/puma/ssa.txt " );
Request.Credentials = new NetworkCredential( " id " , " pwd " );
Request.Method = WebRequestMethods.Ftp.Rename;
Request.Timeout = ( 60000 * 1 ); // 60000 * 1,表示1分鐘
Request.RenameTo = " NewName.txt " ;
FtpWebResponse Response = (FtpWebResponse)Request.GetResponse();
Response.Close();
// 修改目錄名稱
FtpWebRequest Request = (FtpWebRequest)WebRequest.Create( " ftp://111.11.11.11:1234/C/puma/test " );
Request.Credentials = new NetworkCredential( " id " , " pwd " );
Request.Method = WebRequestMethods.Ftp.Rename;
Request.Timeout = ( 60000 * 1 ); // 60000 * 1,表示1分鐘
Request.RenameTo = " test2 " ;
FtpWebResponse Response = (FtpWebResponse)Request.GetResponse();
Response.Close();
// 移除檔案
FtpWebRequest Request = (FtpWebRequest)WebRequest.Create( " ftp://111.11.11.11:1234/C/puma/NewName.txt " );
Request.Credentials = new NetworkCredential( " id " , " pwd " );
Request.Method = WebRequestMethods.Ftp.DeleteFile;
Request.Timeout = ( 60000 * 1 ); // 60000 * 1,表示1分鐘
FtpWebResponse Response = (FtpWebResponse)Request.GetResponse();
Response.Close();
// 移除目錄
FtpWebRequest Request = (FtpWebRequest)WebRequest.Create( " ftp://111.11.11.11:1234/C/puma/test2 " );
Request.Credentials = new NetworkCredential( " id " , " pwd " );
Request.Method = WebRequestMethods.Ftp.RemoveDirectory;
Request.Timeout = ( 60000 * 1 ); // 60000 * 1,表示1分鐘
FtpWebResponse Response = (FtpWebResponse)Request.GetResponse();
Response.Close();
如果本文对你有所帮助,请打赏——1元就足够感动我:)
联系邮箱:intdb@qq.com
我的GitHub: https://github.com/vipstone
联系邮箱:intdb@qq.com
我的GitHub: https://github.com/vipstone
关注公众号:
作者: 王磊
出处: http://vipstone.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,请标明出处。