System.Windows.Forms.FolderBrowserDialog fbd = null;
private Thread invokeThread;
private System.Windows.Forms.DialogResult result;
public string ChooseFolderPath()
{
if(fbd != null)
fbd.Dispose();
fbd = new System.Windows.Forms.FolderBrowserDialog();
fbd.RootFolder = System.Environment.SpecialFolder.MyDocuments;
fbd.ShowNewFolderButton = true;
fbd.Description = "选择导出作品路径";
invokeThread = new Thread(new ThreadStart(InvokeMethod));
invokeThread.SetApartmentState(ApartmentState.STA);
invokeThread.Start();
invokeThread.Join();
if (result == System.Windows.Forms.DialogResult.OK)
{
fbd.Dispose();
return fbd.SelectedPath.ToString();
}
else {
fbd.Dispose();
return "";
}
}
网友评论