初级的功能
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
|
||||
namespace FATrace.Com
|
||||
{
|
||||
@@ -16,9 +17,19 @@ namespace FATrace.Com
|
||||
/// </summary>
|
||||
/// <param name="configKey"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetVideoName(string Path,string Code)
|
||||
public static string GetVideoName(string basePath,string Code)
|
||||
{
|
||||
return $"{Path}\\{DateTime.Now.ToString("yyyy-MM-dd HHmmss")} {Code}.mp4";
|
||||
// 清洗非法文件名字符,避免保存失败
|
||||
string safeCode = Code;
|
||||
try
|
||||
{
|
||||
var invalid = System.IO.Path.GetInvalidFileNameChars();
|
||||
safeCode = new string(Code.Where(c => !invalid.Contains(c)).ToArray());
|
||||
if (string.IsNullOrWhiteSpace(safeCode)) safeCode = "CODE";
|
||||
}
|
||||
catch { }
|
||||
|
||||
return $"{basePath}\\{DateTime.Now.ToString("yyyy-MM-dd HHmmss")} {safeCode}.mp4";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user