36 lines
1003 B
C#
36 lines
1003 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.IO;
|
|
|
|
namespace FATrace.Com
|
|
{
|
|
/// <summary>
|
|
/// NVR 公共的类
|
|
/// </summary>
|
|
public class NVRCom
|
|
{
|
|
/// <summary>
|
|
/// 获取视频名称
|
|
/// </summary>
|
|
/// <param name="configKey"></param>
|
|
/// <returns></returns>
|
|
public static string GetVideoName(string basePath,string Code)
|
|
{
|
|
// 清洗非法文件名字符,避免保存失败
|
|
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";
|
|
}
|
|
}
|
|
}
|