我想要求用户使用方法指定文件夹路径并将其保存在数组中,然后允许稍后使用该数组。我遇到的问题是定义返回类型。我应该如何构建该方法?c#内部字符串数组方法
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
}
}
P.S.我只是开始学习使用方法。
什么是你需要的返回类型点很重要?只是在这里替换==> 内部[ - > void < - ] selectFolderTxt( –