怎样用C#删除上传到服务器的文件?谢谢 做一个WebService就可以了,在执行某个事件的时候去请求这个服务 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 using System.IOstring path = @"c:\temp\MyTest.txt";File.Delete(path); FileInfo file=new FileInfo(Server.MapPath(fileUrl));file.Delete(); 希望对你有所帮助 private void RemoveFiles(string strPath) { try { System.IO.DirectoryInfo di = new DirectoryInfo(strPath); FileInfo[] fiArr = di.GetFiles(); foreach (FileInfo fi in fiArr) { if(fi.Extension.ToString() ==".gif" ) { // if file is older than 2 minutes, we'll clean it up TimeSpan min = new TimeSpan(0,0,0,2,0); if(fi.CreationTime < DateTime.Now.Subtract(min)) { fi.Delete(); } } } } catch {} } 希望对你有所帮助: private void RemoveFiles(string strPath) { try { System.IO.DirectoryInfo di = new DirectoryInfo(strPath); FileInfo[] fiArr = di.GetFiles(); foreach (FileInfo fi in fiArr) { if(fi.Extension.ToString() ==".gif" ) { // if file is older than 2 minutes, we'll clean it up TimeSpan min = new TimeSpan(0,0,0,2,0); if(fi.CreationTime < DateTime.Now.Subtract(min)) { fi.Delete(); } } } } catch {} } PerformanceCounter使用问题 C#用Graphics绘制雪人【共享】 请大家推荐几本关于C#开发软件的书 各位大虾,帮帮忙,小弟初学c#,请多指教,up有分 请问这效果是用的那个controls??是ListView还是什么呢? vs2010 退格键无法删除代码 求助:quartz 表达式 10点到10点20 每十分钟执行一次 新手请教,C#中的windows应用程序如何打包? 如何与Word,Excle等联系 急上加急,救人如救火!!!VS.NET的安装问题 能否在运行时检测类是否实现某个接口? 紧急征求各位意见,具有爱国心的请进来。。。。。。。。。。
string path = @"c:\temp\MyTest.txt";
File.Delete(path);
file.Delete();
{
try
{
System.IO.DirectoryInfo di = new DirectoryInfo(strPath);
FileInfo[] fiArr = di.GetFiles();
foreach (FileInfo fi in fiArr)
{
if(fi.Extension.ToString() ==".gif" )
{
// if file is older than 2 minutes, we'll clean it up
TimeSpan min = new TimeSpan(0,0,0,2,0);
if(fi.CreationTime < DateTime.Now.Subtract(min))
{
fi.Delete();
}
}
}
}
catch
{}
}
private void RemoveFiles(string strPath)
{
try
{
System.IO.DirectoryInfo di = new DirectoryInfo(strPath);
FileInfo[] fiArr = di.GetFiles();
foreach (FileInfo fi in fiArr)
{
if(fi.Extension.ToString() ==".gif" )
{
// if file is older than 2 minutes, we'll clean it up
TimeSpan min = new TimeSpan(0,0,0,2,0);
if(fi.CreationTime < DateTime.Now.Subtract(min))
{
fi.Delete();
}
}
}
}
catch
{}
}