本文介绍了在C#中删除文件的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.我试图删除驱动器中的文件之一,但并未删除,这是我在按钮单击事件中编写的代码.

try
       {
           //System.IO.File.Delete(@"E:\sasi\ss");
           string path = @"e:\sasi\delt.doc";
           FileInfo myfileinf = new FileInfo(path);
           myfileinf.Delete();

           Response.Write("<script>alert(''deleted'')</script>");
       }
       catch (Exception  ex)
       {

           Label l = new Label();
           l.Text = ex.Message;
           Form.Controls.Add(l);
       }
解决方案


hi to all. i am trying to delete one of file in my drive but it is not deleting this is my code written in button click event.

try
       {
           //System.IO.File.Delete(@"E:\sasi\ss");
           string path = @"e:\sasi\delt.doc";
           FileInfo myfileinf = new FileInfo(path);
           myfileinf.Delete();

           Response.Write("<script>alert(''deleted'')</script>");
       }
       catch (Exception  ex)
       {

           Label l = new Label();
           l.Text = ex.Message;
           Form.Controls.Add(l);
       }
解决方案


这篇关于在C#中删除文件的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-30 06:47
查看更多