Tuesday, February 7, 2012

Delete a file from directory using ASP.Net


Delete a file from directory
This program will delete a file from directory.  Add following namespace
Using system.io;
  • At first within if condition it is checking wheather file is exhists or not.
  • Delete method of File class is used for file delete parpuse
            if (File.Exists(fname))
            {
                File.Delete(fname);
                this.Label1.Text = "<font color=green>" + "File deleted" + "</font>";
                show();
            }
            else
            {
                this.Label1.Text = "<font color=green>" + "File not exhists" + "</font>";
            }

No comments:

Post a Comment