unity 调用windows选择文件并导出路径

2019-07-24  本文已影响0人  RichMartin
   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 "";
           }
       }
上一篇下一篇

猜你喜欢

热点阅读