Example #1
0
        public string OpenFileDialog()
        {
            string            filename     = "";
            GetOpenFileDialog oGetFileName = new GetOpenFileDialog();

            oGetFileName.Filter           = "SQF Files|*.sqf|Text Files|*.txt";
            oGetFileName.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            Thread threadGetFile = new Thread(new ThreadStart(oGetFileName.GetFileName));

            threadGetFile.SetApartmentState(ApartmentState.STA);
            try
            {
                threadGetFile.Start();
                while (!threadGetFile.IsAlive)
                {
                    oGetFileName.SetFocus();
                    Thread.Sleep(1);
                }
                ;
                Thread.Sleep(1);
                threadGetFile.Join();
                filename = oGetFileName.FileName;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            threadGetFile = null;
            oGetFileName  = null;
            return(filename);
        }
Example #2
0
 public string OpenFileDialog()
 {
     string filename = "";
     GetOpenFileDialog oGetFileName = new GetOpenFileDialog();
     
     oGetFileName.Filter = "SQF Files|*.sqf|Text Files|*.txt";
     oGetFileName.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
     Thread threadGetFile = new Thread(new ThreadStart(oGetFileName.GetFileName));
     threadGetFile.SetApartmentState(ApartmentState.STA);
     try
     {
         threadGetFile.Start();
         while (!threadGetFile.IsAlive) {
             oGetFileName.SetFocus();
             Thread.Sleep(1);
         };
         Thread.Sleep(1);
         threadGetFile.Join();
         filename = oGetFileName.FileName;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     threadGetFile = null;
     oGetFileName = null;
     return filename;
 }