本文整理汇总了C#中FtpClient.ChangeDirectoryMultiPath方法的典型用法代码示例。如果您正苦于以下问题:C# FtpClient.ChangeDirectoryMultiPath方法的具体用法?C# FtpClient.ChangeDirectoryMultiPath怎么用?C# FtpClient.ChangeDirectoryMultiPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FtpClient
的用法示例。
在下文中一共展示了FtpClient.ChangeDirectoryMultiPath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UploadPackage
public void UploadPackage(string packagePath, string packageVersion)
{
if (!_hasAlreadyFixedStrings)
FixProperties();
_packageFtpClient = new FtpClient();
_packageFtpClient = new FtpClient(Host, Port, Protocol)
{
DataTransferMode = UsePassiveMode ? TransferMode.Passive : TransferMode.Active,
FileTransferType = TransferType.Binary,
Proxy = Proxy != null ? new HttpProxyClient(Proxy.Address.ToString()) : null
};
try
{
_packageFtpClient.TransferProgress += TransferProgressChangedEventHandler;
_packageFtpClient.PutFileAsyncCompleted += UploadPackageFinished;
_packageFtpClient.Open(Username, Password.ConvertToUnsecureString());
_packageFtpClient.ChangeDirectoryMultiPath(Directory);
_packageFtpClient.MakeDirectory(packageVersion);
_packageFtpClient.ChangeDirectory(packageVersion);
_packageFtpClient.PutFileAsync(packagePath, FileAction.Create);
_uploadPackageResetEvent.WaitOne();
}
finally
{
_packageFtpClient.Close();
_uploadPackageResetEvent.Reset();
}
}
示例2: IsExisting
public bool IsExisting(string destinationName)
{
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);
string nameList = null;
try
{
nameList = ftp.GetNameList(destinationName);
}
catch (Exception ex)
{
if (ex.Message.Contains("No such file or directory") || ex.Message.Contains("Directory not found"))
return false;
}
return !string.IsNullOrEmpty(nameList);
}
finally
{
ftp.Close();
}
}
示例3: UploadFile
public void UploadFile(string filePath)
{
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.PutFile(filePath, FileAction.Create);
}
finally
{
ftp.Close();
}
}
示例4: InternalMoveContent
public void InternalMoveContent(string directory, string aimPath)
{
foreach (FtpItem item in ListDirectoriesAndFiles(directory, false)
.Where(
item => item.FullPath != aimPath && item.FullPath != aimPath.Substring(aimPath.Length - 1)))
{
FtpClient ftp = null;
try
{
ftp = new FtpClient(Host, Port, Protocol)
{
DataTransferMode = UsePassiveMode ? TransferMode.Passive : TransferMode.Active,
FileTransferType = TransferType.Binary,
Proxy = Proxy != null ? new HttpProxyClient(Proxy.Address.ToString()) : null
};
ftp.Open(Username, Password.ConvertToUnsecureString());
Guid guid; // Just for the out-reference of TryParse
if (item.ItemType == FtpItemType.Directory && UpdateVersion.IsValid(item.Name))
{
ftp.ChangeDirectoryMultiPath(aimPath);
if (!IsExisting(aimPath, item.Name))
ftp.MakeDirectory(item.Name);
ftp.ChangeDirectoryMultiPath(item.Name);
InternalMoveContent(item.FullPath, String.Format("{0}/{1}", aimPath, item.Name));
DeleteDirectory(item.FullPath);
}
else if (item.ItemType == FtpItemType.File &&
(item.Name == "updates.json" || Guid.TryParse(item.Name.Split('.')[0], out guid)))
// Second condition determines whether the item is a package-file or not
{
if (!IsExisting(aimPath, item.Name))
{
// "MoveFile"-method damages the files, so we do it manually with a work-around
//ftp.MoveFile(item.FullPath, String.Format("{0}/{1}", aimPath, item.Name));
string localFilePath = Path.Combine(Path.GetTempPath(), item.Name);
ftp.GetFile(item.FullPath, localFilePath, FileAction.Create);
ftp.PutFile(localFilePath, String.Format("{0}/{1}", aimPath, item.Name),
FileAction.Create);
File.Delete(localFilePath);
}
DeleteFile(item.ParentPath, item.Name);
}
}
finally
{
if (ftp != null)
ftp.Close();
}
}
}