Browse Source

保存添加提示当前位置存在一个文件夹,删除或创建一个新文件夹!

zhangjiaxin 3 years ago
parent
commit
5a42e6699d

+ 9 - 2
OTSIncAMeasureApp/0-OTSModel/Measure/ParamData/COTSMsrPrjResultData.cs

@@ -543,7 +543,7 @@ namespace OTSModelSharp
             String strPathName = "";
             // file open dialog
             SaveFileDialog saveFileDialog = new SaveFileDialog();
-            saveFileDialog.FileName = m_strPathName.Split('\\')[m_strPathName.Split('\\').Length-1];
+            saveFileDialog.FileName = m_strPathName.Split('\\')[m_strPathName.Split('\\').Length - 1];
             saveFileDialog.Filter = "Probject Files (*.prj)|*.prj|All files (*.*)|*.*";
             if (saveFileDialog.ShowDialog() != DialogResult.OK)
             {
@@ -552,7 +552,14 @@ namespace OTSModelSharp
             }
             // get file pathname
             strPathName = saveFileDialog.FileName;
-
+            string DirectoryName = Path.GetDirectoryName(strPathName);
+            DirectoryInfo Folder = new DirectoryInfo(DirectoryName);
+            List<string> FolderNames = new List<string>();
+            if (Folder.GetDirectories().Length != 0)
+            {
+                MessageBox.Show("Save failed, a folder exists in the current location, delete or create a new one!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                return false;
+            }
             //保存测量项目文件 .prj
             XmlDocument doc = new XmlDocument();
             //添加xml文件头申明