本文整理汇总了C#中SftpClient.Get方法的典型用法代码示例。如果您正苦于以下问题:C# SftpClient.Get方法的具体用法?C# SftpClient.Get怎么用?C# SftpClient.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SftpClient
的用法示例。
在下文中一共展示了SftpClient.Get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_Sftp_SftpFile_MoveTo
public void Test_Sftp_SftpFile_MoveTo()
{
using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
{
sftp.Connect();
string uploadedFileName = Path.GetTempFileName();
string remoteFileName = Path.GetRandomFileName();
string newFileName = Path.GetRandomFileName();
this.CreateTestFile(uploadedFileName, 1);
using (var file = File.OpenRead(uploadedFileName))
{
sftp.UploadFile(file, remoteFileName);
}
var sftpFile = sftp.Get(remoteFileName);
sftpFile.MoveTo(newFileName);
Assert.AreEqual(newFileName, sftpFile.Name);
sftp.Disconnect();
}
}
示例2: Test_Get_Invalid_Directory
public void Test_Get_Invalid_Directory()
{
using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
{
sftp.Connect();
sftp.Get("/xyz");
}
}
示例3: Test_Get_File_Null
public void Test_Get_File_Null()
{
using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
{
sftp.Connect();
var file = sftp.Get(null);
sftp.Disconnect();
}
}
示例4: Test_Get_Root_Directory
public void Test_Get_Root_Directory()
{
using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
{
sftp.Connect();
var directory = sftp.Get("/");
Assert.AreEqual("/", directory.FullName);
Assert.IsTrue(directory.IsDirectory);
Assert.IsFalse(directory.IsRegularFile);
}
}
示例5: Test_Get_File
public void Test_Get_File()
{
using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
{
sftp.Connect();
sftp.UploadFile(new MemoryStream(), "abc.txt");
var file = sftp.Get("abc.txt");
Assert.AreEqual("/home/tester/abc.txt", file.FullName);
Assert.IsTrue(file.IsRegularFile);
Assert.IsFalse(file.IsDirectory);
}
}
示例6: GetTest
public void GetTest()
{
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
SftpFile expected = null; // TODO: Initialize to an appropriate value
SftpFile actual;
actual = target.Get(path);
Assert.AreEqual(expected, actual);
Assert.Inconclusive("Verify the correctness of this test method.");
}