/[AnywhereTS-MSSQL]/trunk/TSAdminTool/frmAddTFTP.cs
ViewVC logotype

Diff of /trunk/TSAdminTool/frmAddTFTP.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/TSAdminTool/frmAddTFTP.cs	2012/07/11 14:19:13	4
+++ trunk/TSAdminTool/frmAddTFTP.cs	2012/07/16 12:58:43	180
@@ -6,6 +6,7 @@
 using System.Text;
 using System.Windows.Forms;
 using System.IO;
+using System.Threading;
 
 namespace AnywhereTS
 {
@@ -35,6 +36,10 @@
             {
                 this.Cursor = Cursors.Default;
                 MessageBox.Show("Invalid path.");
+                using (log4net.NDC.Push(string.Format("path={0}", inputstring)))
+                {
+                    Logging.ATSAdminLog.Warn("Invalid path.");
+                }
                 textInput.Focus();
                 return;
             }
@@ -44,38 +49,37 @@
             {
                 MessageBox.Show("Cannot find or access directory '" + inputstring + "' Please check spelling and rights!");
 
+                using (log4net.NDC.Push(string.Format("path={0}", inputstring)))
+                {
+                    Logging.ATSAdminLog.Warn("Cannot find or access directory.");
+                }
                 textInput.SelectAll();
                 textInput.Focus();
                 return;
             }
-            
+
             DialogResult = DialogResult.OK;
         }
 
+
+        string tftp_path = string.Empty;
         private void btnBrowse_Click(object sender, EventArgs e)
         {
-        // Show the FolderBrowserDialog.
-
-        Rebrowse:
+            var t = new Thread(new ThreadStart(CreateFolderBrowser));
+            t.IsBackground = true;
+            t.SetApartmentState(ApartmentState.STA);
+            t.Start();
+            while (t.IsAlive) { Application.DoEvents(); }
+            textInput.Text = tftp_path;
+            textInput.Select();
+        }
+        private void CreateFolderBrowser()
+        {
+            folderBrowserDialog = new FolderBrowserDialog();
+            folderBrowserDialog.RootFolder = Environment.SpecialFolder.MyComputer;
             DialogResult result = folderBrowserDialog.ShowDialog();
-            if (result == DialogResult.OK)
-            {
-                string strPath; // The path provided by the user 
-
-                // Browse to a folder by displaying the folder browse Dialog
-                try
-                {
-                    strPath = folderBrowserDialog.SelectedPath.Trim();
-                }
-                catch (NotSupportedException)
-                {   // User has browsed to a non folder
-                    MessageBox.Show("Object is not a file folder.");
-                    goto Rebrowse;
-                }
-                textInput.Text = strPath;
-                textInput.Select();
-            }
-
+            if (result != DialogResult.OK) return;
+            tftp_path = folderBrowserDialog.SelectedPath.Trim();
         }
 
         private void frmAddTFTP_Load(object sender, EventArgs e)

 

  ViewVC Help
Powered by ViewVC 1.1.22