我当前的代码看起来像这样
var dialog = new CommonopenfileDialog();dialog.IsFolderPicker = true;if (dialog.ShowDialog() == CommonfileDialogResult.Ok){ SelectedFolderPath = dialog.filename;}解决方法 在我头顶,这是我做的
var dialog = new CommonopenfileDialog { EnsurePathExists = true,EnsurefileExists = false,AllowNonfileSystemItems = false,Defaultfilename = "Select Folder",Title = "Select The Folder To Process" }; dialog.SetopenbuttonText("Select Folder"); if (dialog.ShowDialog() == CommonfileDialogResult.Ok) dirtoprocess = Directory.Exists(dialog.filename) ? dialog.filename : Path.GetDirectoryname(dialog.filename);
编辑:神圣2年前蝙蝠侠!
似乎几乎没有变化,下面的片段似乎做了这个工作
var openFolder = new CommonopenfileDialog();openFolder.AllowNonfileSystemItems = true;openFolder.Multiselect = true;openFolder.IsFolderPicker = true;openFolder.Title = "Select folders with jpg files";if (openFolder.ShowDialog() != CommonfileDialogResult.Ok){ MessageBox.Show("No Folder selected"); return;}// get all the directorIEs in selected dirctoryvar dirs = openFolder.filenames.ToArray();总结
以上是内存溢出为你收集整理的c# – 如何使CommonOpenFileDialog仅选择文件夹,但仍显示文件?全部内容,希望文章能够帮你解决c# – 如何使CommonOpenFileDialog仅选择文件夹,但仍显示文件?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)