本文整理汇总了C#中SftpClient.CreateDirectory方法的典型用法代码示例。如果您正苦于以下问题:C# SftpClient.CreateDirectory方法的具体用法?C# SftpClient.CreateDirectory怎么用?C# SftpClient.CreateDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SftpClient
的用法示例。
在下文中一共展示了SftpClient.CreateDirectory方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_Sftp_CreateDirectory_Already_Exists
public void Test_Sftp_CreateDirectory_Already_Exists()
{
using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
{
sftp.Connect();
sftp.CreateDirectory("test");
sftp.CreateDirectory("test");
sftp.Disconnect();
}
}
示例2: Test_Sftp_CreateDirectory_Without_Connecting
public void Test_Sftp_CreateDirectory_Without_Connecting()
{
using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
{
sftp.CreateDirectory("test");
}
}
示例3: Test_Sftp_CreateDirectory_Invalid_Path
public void Test_Sftp_CreateDirectory_Invalid_Path()
{
using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
{
sftp.Connect();
sftp.CreateDirectory("/abcdefg/abcefg");
sftp.Disconnect();
}
}
示例4: Test_Sftp_CreateDirectory_In_Current_Location
public void Test_Sftp_CreateDirectory_In_Current_Location()
{
using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
{
sftp.Connect();
sftp.CreateDirectory("test");
sftp.Disconnect();
}
}
示例5: Test_Sftp_DeleteDirectory
public void Test_Sftp_DeleteDirectory()
{
using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
{
sftp.Connect();
sftp.CreateDirectory("abcdef");
sftp.DeleteDirectory("abcdef");
sftp.Disconnect();
}
}
示例6: Test_Sftp_CreateDirectory_In_Forbidden_Directory
public void Test_Sftp_CreateDirectory_In_Forbidden_Directory()
{
if (Resources.USERNAME == "root")
Assert.Fail("Must not run this test as root!");
using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
{
sftp.Connect();
sftp.CreateDirectory("/sbin/test");
sftp.Disconnect();
}
}
示例7: Test_Sftp_CreateDirectory_Null
public void Test_Sftp_CreateDirectory_Null()
{
using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
{
sftp.CreateDirectory(null);
}
}
示例8: Test_Sftp_Change_Directory
public void Test_Sftp_Change_Directory()
{
using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
{
sftp.Connect();
Assert.AreEqual(sftp.WorkingDirectory, "/home/tester");
sftp.CreateDirectory("test1");
sftp.ChangeDirectory("test1");
Assert.AreEqual(sftp.WorkingDirectory, "/home/tester/test1");
sftp.CreateDirectory("test1_1");
sftp.CreateDirectory("test1_2");
sftp.CreateDirectory("test1_3");
var files = sftp.ListDirectory(".");
Assert.IsTrue(files.First().FullName.StartsWith(string.Format("{0}", sftp.WorkingDirectory)));
sftp.ChangeDirectory("test1_1");
Assert.AreEqual(sftp.WorkingDirectory, "/home/tester/test1/test1_1");
sftp.ChangeDirectory("../test1_2");
Assert.AreEqual(sftp.WorkingDirectory, "/home/tester/test1/test1_2");
sftp.ChangeDirectory("..");
Assert.AreEqual(sftp.WorkingDirectory, "/home/tester/test1");
sftp.ChangeDirectory("..");
Assert.AreEqual(sftp.WorkingDirectory, "/home/tester");
files = sftp.ListDirectory("test1/test1_1");
Assert.IsTrue(files.First().FullName.StartsWith(string.Format("{0}/test1/test1_1", sftp.WorkingDirectory)));
sftp.ChangeDirectory("test1/test1_1");
Assert.AreEqual(sftp.WorkingDirectory, "/home/tester/test1/test1_1");
sftp.ChangeDirectory("/home/tester/test1/test1_1");
Assert.AreEqual(sftp.WorkingDirectory, "/home/tester/test1/test1_1");
sftp.ChangeDirectory("/home/tester/test1/test1_1/../test1_2");
Assert.AreEqual(sftp.WorkingDirectory, "/home/tester/test1/test1_2");
sftp.ChangeDirectory("../../");
sftp.DeleteDirectory("test1/test1_1");
sftp.DeleteDirectory("test1/test1_2");
sftp.DeleteDirectory("test1/test1_3");
sftp.DeleteDirectory("test1");
sftp.Disconnect();
}
}
示例9: Test_Sftp_ListDirectory_HugeDirectory
public void Test_Sftp_ListDirectory_HugeDirectory()
{
using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
{
sftp.Connect();
// Create 10000 directory items
for (int i = 0; i < 10000; i++)
{
sftp.CreateDirectory(string.Format("test_{0}", i));
Debug.WriteLine("Created " + i);
}
var files = sftp.ListDirectory(".");
// Ensure that directory has at least 10000 items
Assert.IsTrue(files.Count() > 10000);
sftp.Disconnect();
}
}
示例10: CreatSSHDir
private static void CreatSSHDir(SftpClient ssh, string file)
{
var newDir = Tools.Misc.GetUnixDirecoryOfFile(file);
if (ssh.Exists(newDir)) return;
string[] dirs = new string[newDir.ToCharArray().Count(x => x == '/')];
dirs[0] = newDir;
for (int i = 1; i < dirs.Count(); i++)
{
dirs[i] = Tools.Misc.GetUnixDirecoryOfFile(dirs[i - 1]);
}
for (int i = dirs.Count()-1; i >= 0; i--)
{
if (ssh.Exists(dirs[i])) continue;
ssh.CreateDirectory(dirs[i]);
}
}
示例11: CreateDirectoryTest
public void CreateDirectoryTest()
{
ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
SftpClient target = new SftpClient(connectionInfo); // TODO: Initialize to an appropriate value
string path = string.Empty; // TODO: Initialize to an appropriate value
target.CreateDirectory(path);
Assert.Inconclusive("A method that does not return a value cannot be verified.");
}