Remove file From Server :DotNet
in my Previous Post you get to know how to Open Any file from Server
Now If I am not wrong
You mean to say you want to send a Input by which the output should come with Delete a file from Server.
So When you Are working with Input Output the first thing Is
Add IO Namespace
1)using System..IO;
In the Head Of your .cs file .
2)and Type Below code With Your Own Understanding
FileInfo TheFile = new FileInfo(MapPath(".") + "\\" + txtFile.Text);
if (TheFile.Exists)
{
File.Delete(MapPath(".") + "\\" + txtFile.Text);
}
Use Above Code Either In Page Load Or An Event !
To Remind you dont act as a fool to delete file from any other server where your this file does not exist!
in my Previous Post you get to know how to Open Any file from Server
Now If I am not wrong
You mean to say you want to send a Input by which the output should come with Delete a file from Server.
So When you Are working with Input Output the first thing Is
Add IO Namespace
1)using System..IO;
In the Head Of your .cs file .
2)and Type Below code With Your Own Understanding
FileInfo TheFile = new FileInfo(MapPath(".") + "\\" + txtFile.Text);
if (TheFile.Exists)
{
File.Delete(MapPath(".") + "\\" + txtFile.Text);
}
Use Above Code Either In Page Load Or An Event !
To Remind you dont act as a fool to delete file from any other server where your this file does not exist!
No comments:
Post a Comment