Skip to content

Commit

Permalink
Add New Folder Auto Create
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinerising committed Mar 25, 2024
1 parent fe29eca commit 069f2bf
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions ComTransfer/ComPort.cs
Original file line number Diff line number Diff line change
Expand Up @@ -361,27 +361,48 @@ public string GetDirectoryInfo()
/// <returns>文件保存地址</returns>
public string GetDirectory(string extension, string filename)
{
string target;
string path = GetLocation(filename);
if (path != null)
{
return path;
target = path;
}
if (extension == null)
else if (extension == null)
{
return DefaultDirectory;
target = DefaultDirectory;
}
if (directoryDict == null)
else if (directoryDict == null)
{
return DefaultDirectory;
target = DefaultDirectory;
}
else if (!directoryDict.ContainsKey(extension.ToUpper()))
{
return directoryDict["*"];
target = directoryDict["*"];
}
else
{
return directoryDict[extension.ToUpper()];
target = directoryDict[extension.ToUpper()];
}
if (string.IsNullOrEmpty(target))
{
AddLog("程序故障", "无法正确找到目标存储位置:" + filename);
}
else
{
try
{
if (!Directory.Exists(target))
{
AddLog("操作记录", "正在建立新文件夹:" + target);
Directory.CreateDirectory(target);
}
}
catch
{
AddLog("程序故障", "无法建立文件夹:" + target);
}
}
return target;
}

/// <summary>
Expand Down

0 comments on commit 069f2bf

Please sign in to comment.