【发布时间】:2018-10-30 14:36:37
【问题描述】:
我正在尝试通过 FTP 从设备下载一些文件。但现在我对OpenFileDialog 有一个问题。当我选择一个文件时,它首先开始缓存,这需要很长时间。我只想知道我在对话框中选择了哪个文件,没有别的。然后,通过WebClient下载。
这是一个代码sn-p:
OpenFileDialog dialog = new OpenFileDialog();
dialog.InitialDirectory = ftpAddress;
DialogResult result = dialog.ShowDialog(this);
if(result != DialogResult.OK)
{
return false;
}
string selectedLogFile = dialog.FileName;
WebClient webclient = new WebClient();
webclient.Credentials = new NetworkCredential(login, password);
webclient.DownloadFile(ftpAddress+ selectedLogFile, exportTo + selectedLogFile);
【问题讨论】:
-
openfiledialog 正在使用资源管理器。这将是您应该为其编写自定义对话框的内容。
-
所以没有其他解决方案可以让我获得选定的文件名吗? ://
标签: c# .net winforms ftp openfiledialog