【发布时间】:2016-02-25 08:08:33
【问题描述】:
我想要求用户使用方法指定文件夹路径并将其保存在数组中,然后允许以后使用该数组。我遇到的问题是定义返回类型。我应该如何构建方法?
internal void selectFolderTxt(out string [] files)
{
FolderBrowserDialog fbd = new FolderBrowserDialog();
fbd.RootFolder = Environment.SpecialFolder.MyComputer;//This causes the folder to begin at the root folder or your documents
if (fbd.ShowDialog() == DialogResult.OK)
{
string[] files = Directory.GetFiles(fbd.SelectedPath, "*.txt", SearchOption.AllDirectories);//change this to specify file type
}
else
{
// prevents crash
}
}
附:我才刚刚开始学习使用方法。
【问题讨论】:
-
你需要的返回类型是什么?只需在这里替换 ==> 内部 [-->void