本文介绍了使用WinSCP赋予.NET程序集特定扩展名列表文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用WinSCP赋予.NET程序集做了下载和上传通过与C#.NET SFTP。我有下载功能工作,但我正在寻找一种方法来在列(或至少具有特定扩展名上市),因此用户只能从特定的扩展名的文件(如<$ c键选择远程服务器上的文件$ C> .TXT ),以获得他们想要的文件。

I am using WinSCP .NET assembly to do a download and upload through SFTP with C# .NET. I have the download function working but I am looking for a way to have the files in the remote server listed (or at least listed with a specific extension) so user only have to choose from those files with the specific extension (like .txt) to get the files they want.

有没有办法做到这一点与WinSCP赋予.NET程序集?

Is there a way to do that with WinSCP .NET assembly?

推荐答案

使用:

RemoteDirectoryInfo directory = session.ListDirectory("/home/martin/");

foreach (RemoteFileInfo fileInfo in directory.Files)
{
    string extension = Path.GetExtension(fileInfo.Name);
    if (string.Compare(extension, ".txt", true) == 0)
    {
        Console.WriteLine("Adding {0} to listing", fileInfo.Name);
    }
}

这篇关于使用WinSCP赋予.NET程序集特定扩展名列表文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 04:18