将文件移动到另一个FTP位置时,必须使用RenameTo新的FTP位置.
在此示例中,您如何使用RenameTo移动到新的FTP位置?
FtpWebRequest ftpRequest = null;
FtpWebResponse ftpResponse = null;
try
{
ftpRequest = (FtpWebRequest)WebRequest.Create("ftp://mysite.com/folder1/fileName.ext");
ftpRequest.Credentials = new NetworkCredential("user", "pass");
ftpRequest.UseBinary = true;
ftpRequest.UsePassive = true;
ftpRequest.KeepAlive = true;
ftpRequest.Method = WebRequestMethods.Ftp.Rename;
ftpRequest.RenameTo = "ftp://mysite.com/folder2/fileName.ext";
ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();
ftpResponse.Close();
ftpRequest = null;
}
catch (Exception ex) { Label1.Text = (ex.ToString()); }
Run Code Online (Sandbox Code Playgroud) 我有长度大于150个字符的字符串.我想删除前17个字符,剩下的就剩下了.我在ASP.net 4.5中使用Substring方法但是我在str0收到错误消息:"System.ArgumentOutOfRangeException".
public static string extract(string dirinfo)
{
Int32 lensub = Convert.ToInt32(dirinfo.Length);
string str0 = dirinfo.Substring(17, lensub);
return str0;
}
Run Code Online (Sandbox Code Playgroud)