本文整理汇总了C#中FtpClient.Rename方法的典型用法代码示例。如果您正苦于以下问题:C# FtpClient.Rename方法的具体用法?C# FtpClient.Rename怎么用?C# FtpClient.Rename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FtpClient
的用法示例。
在下文中一共展示了FtpClient.Rename方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Rename
public static void Rename() {
using (FtpClient conn = new FtpClient()) {
conn.Host = "localhost";
conn.Credentials = new NetworkCredential("ftptest", "ftptest");
// renaming a directory is dependant on the server! if you attempt it
// and it fails it's not because System.Net.FtpClient has a bug!
conn.Rename("/full/or/relative/path/to/src", "/full/or/relative/path/to/dest");
}
}
示例2: UnsetOnlineStatus
private bool UnsetOnlineStatus(FtpClient cl)
{
UserStatus onlineStatus = UserStatus.Unknown;
try
{
string[] sa;
sa = cl.GetNameListing(_ftpSkypeDir + _account);
foreach (var iterateStatus in Enum.GetValues(typeof (UserStatus)))
{
bool found = false;
foreach (var s in sa)
{
int indir;
if (int.TryParse(s.Substring(0,s.IndexOf(".", StringComparison.Ordinal)), out indir))
{
if (indir == (int) iterateStatus)
{
found = true;
break;
}
}
}
if (!found)
{
onlineStatus = (UserStatus) iterateStatus;
break;
}
}
if (cl.FileExists(_ftpSkypeDir + _account + "/current.png"))
{
cl.Rename(_ftpSkypeDir + _account + "/current.png",
_ftpSkypeDir + _account + "/" + (int)onlineStatus + ".png");
}
}
catch (Exception)
{
return false;
}
return true;
}
示例3: RenameDirectory
public void RenameDirectory(string oldName, string newName)
{
if (!_hasAlreadyFixedStrings)
FixProperties();
var ftp = new FtpClient(Host, Port, Protocol)
{
DataTransferMode = UsePassiveMode ? TransferMode.Passive : TransferMode.Active,
FileTransferType = TransferType.Binary,
Proxy = Proxy != null ? new HttpProxyClient(Proxy.Address.ToString()) : null
};
try
{
ftp.Open(Username, Password.ConvertToUnsecureString());
ftp.ChangeDirectoryMultiPath(Directory);
ftp.Rename(oldName, newName);
}
finally
{
ftp.Close();
}
}