如何通过通配符来删除文件? 我想用通配符来删除一批文件,比如是??02????.txt、????02??.txt等这种文件,在C#中应该如何去删除这些文件呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 foreach(string FileName in Directory.GetFiles(@"c:\temp", "???-*")){ string strFile = Path.GetFileName(FileName); if (Regex.IsMatch(strFile, @"^\d{2}-")) { strFile = Path.GetDirectoryName(FileName) + "\\" + strFile.Substring(4); if (!File.Exists(strFile )) File.Delete(strFile); }}或GetFiles("*.txt") 直接调用dos命令行算了del ??02????.txt 关于swap函数的疑惑。 急!!!C#调用C++的DLL 问题!!! DataTable排序 线程终止问题 c# 写了一个windows服务程序, 如何实现让windows 服务本身实现重新启动? 计划任务 执行应用控制台程序 传递参数 问题发了一个星期了。没人解决我的问题!~~~~~~~~ 事件如何当作参数来传递 如何动态调用dll中的函数(急!在线等待) 请教如何在C#或者其他.net里面使用OWC~那里可以找到资料或者Sample? 如何在treeView控件上选择信息,在pitureBox控件显示图片 想设置第四列为两为小数的数值
foreach(string FileName in Directory.GetFiles(@"c:\temp", "???-*"))
{
string strFile = Path.GetFileName(FileName);
if (Regex.IsMatch(strFile, @"^\d{2}-"))
{
strFile = Path.GetDirectoryName(FileName) + "\\" + strFile.Substring(4);
if (!File.Exists(strFile ))
File.Delete(strFile);
}
}
或GetFiles("*.txt")
del ??02????.txt