想删除指定路径下的所有日志文件,但是要排除其中指定的某个(多个)文件夹,代码如下:
try
{
DirectoryInfo d = new DirectoryInfo( @"\\server01\c$\windows"); DirectoryInfo[] dirs = d.GetDirectories();
foreach (DirectoryInfo item in dirs)
{
string ExcludeRegEx = @"\\server01\c$\windows\System32";
Regex reg = new Regex(ExcludeRegEx, RegexOptions.IgnoreCase);
Match match = reg.Match(item.FullName);
if (match.Success)
{
Console.WriteLine("match success");
}
else
{
Console.WriteLine("match not success");
}
}
}
catch (Exception ex)
{
throw;
}
程序第7行抛出异常,
Message = "parsing \"\\\\server01\\c$\\windows\\System32\" - Unrecognized control character."请问ExcludeRegEx 该如何写??
try
{
DirectoryInfo d = new DirectoryInfo( @"\\server01\c$\windows"); DirectoryInfo[] dirs = d.GetDirectories();
foreach (DirectoryInfo item in dirs)
{
string ExcludeRegEx = @"\\server01\c$\windows\System32";
Regex reg = new Regex(ExcludeRegEx, RegexOptions.IgnoreCase);
Match match = reg.Match(item.FullName);
if (match.Success)
{
Console.WriteLine("match success");
}
else
{
Console.WriteLine("match not success");
}
}
}
catch (Exception ex)
{
throw;
}
程序第7行抛出异常,
Message = "parsing \"\\\\server01\\c$\\windows\\System32\" - Unrecognized control character."请问ExcludeRegEx 该如何写??
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货