本文整理汇总了C#中FtpClient.Split方法的典型用法代码示例。如果您正苦于以下问题:C# FtpClient.Split方法的具体用法?C# FtpClient.Split怎么用?C# FtpClient.Split使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FtpClient
的用法示例。
在下文中一共展示了FtpClient.Split方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Write
public static Stream Write(string path)
{
var diskpath = Paths.Map(path);
if (Paths.IsWritable(path)) return new FileStream(diskpath, FileMode.Create, FileAccess.Write);
else if (CanUseFtp) {
var pipe = new PipeStream();
Tasks.Do(() => {
using (pipe)
using (var ftp = new FtpClient()) {
string dir, name;
ftp.Split(path, out dir, out name);
ftp.ChangeDirectory(dir);
ftp.PutFile(pipe, name, Ftp.FileAction.Create);
ftp.Close();
}
});
return pipe;
}
throw new IOException(string.Format("Path {0} is write protected.", path));
}
示例2: Delete
public static void Delete(IEnumerable<string> paths)
{
paths.Each(path => {
if (path.Contains("*")) All(path).Each(p => Delete(p));
path = Paths.Normalize(path);
var ftppath = path.Substring(1);
var diskpath = Paths.Map(path);
if (Directory.Exists(diskpath)) {
if (Paths.IsWritable(path)) {
try {
Directory.Delete(diskpath, true);
} catch {
var info = new DirectoryInfo(diskpath);
var children = info.EnumerateFileSystemInfos("*", SearchOption.AllDirectories).ToList();
foreach (var file in children.OfType<FileInfo>()) File.Delete(file.FullName);
children.Reverse();
foreach (var dir in children.OfType<DirectoryInfo>()) Directory.Delete(dir.FullName);
}
} else if (CanUseFtp) {
using (var ftp = new FtpClient()) {
ftp.DeleteDirectoryRecursive(ftppath);
ftp.Close();
}
} else throw new IOException(string.Format("Path {0} is write protected.", path));
} else if (File.Exists(diskpath)) {
if (Paths.IsWritable(path)) File.Delete(diskpath);
else if (CanUseFtp) {
using (var ftp = new FtpClient()) {
string dir, name;
ftp.Split(path, out dir, out name);
ftp.ChangeDirectory(dir);
ftp.DeleteFile(name);
ftp.Close();
}
} else throw new IOException(string.Format("Path {0} is write protected.", path));
}
});
}
示例3: Save
public static void Save(Stream src, string path)
{
if (Paths.IsWritable(path)) {
SaveRaw(src, Paths.Map(path));
} else if (CanUseFtp) {
using (var ftp = new FtpClient()) {
string dir, name;
ftp.Split(path, out dir, out name);
ftp.ChangeDirectory(dir);
ftp.PutFile(src, name, Ftp.FileAction.Create);
ftp.Close();
}
} else throw new IOException(string.Format("Path {0} is write protected.", path));
}
示例4: CreateDirectory
public static void CreateDirectory(IEnumerable<string> paths)
{
foreach (var path in paths) {
var diskpath = Paths.Map(path);
if (!Directory.Exists(diskpath)) {
if (Paths.IsWritable(path)) Directory.CreateDirectory(diskpath);
else if (CanUseFtp) {
using (var ftp = new FtpClient()) {
string dir, name;
ftp.Split(path, out dir, out name);
if (!dir.IsNullOrEmpty()) ftp.ChangeDirectory(dir);
ftp.MakeDirectory(name);
ftp.Close();
}
} else throw new IOException(string.Format("Path {0} is write protected.", path));
}
}
}