文件处理

Posted chenze-index

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了文件处理相关的知识,希望对你有一定的参考价值。

一丶删除文件

技术分享图片
 1  public string DelFile(string fileRelativePath)
 2         {
 3 
 4             try
 5             {
 6                 string filePath = Server.MapPath("~" + fileRelativePath);
 7 
 8                 //if (System.IO.File.Exists(filePath))
 9                 //{
10                 //    System.IO.File.Delete(filePath);
11                 //}
12 
13                 FileInfo file = new FileInfo(filePath);
14                 if (file.Exists)
15                 {
16                     file.Delete();
17                 }
18 
19                 return "";
20             }
21             catch (Exception)
22             {
23 
24                 throw;
25             }
26         }
删除

 

以上是关于文件处理的主要内容,如果未能解决你的问题,请参考以下文章