//把路径中的时间提取出来,判断是否和今天一致,一致就不需要拼接,否则就需要拼接
string path = Resouces.ChooseUrl;
string pattern = @"(\d{4}-\d{2}-\d{2})";
Match match = Regex.Match(path, pattern);
if (match.Success)
{
string date = match.Value; //提取到路径中的时间日期
string now = DateTime.Now.ToString("yyyy-MM-dd");
if (now.Equals(date))
Path = Resouces.ChooseUrl;
else
Path = Resouces.ChooseUrl + "\\" + DateTime.Now.ToString("yyyy-MM-dd");
}
C#中通过正则来获取路径中的固定时间日期格式
最新推荐文章于 2024-07-22 16:38:17 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)