asp.net c# delete all files of server.mappath folder

Posted by Vanchi050585 under Regular Expressions on 2/21/2011 | Points: 10 | Views : 13131 | Status : [Member] | Replies : 3
hi all,

asp.net c# delete all files of server.mappath folder when clicking the delete button.

anybody tell the coding for this.

Thanks in Advance.
tvn

Thanks
tvn



Responses

Posted by: Madhu.b.rokkam on: 2/21/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Get the physical directory using the Server.MapPath and substring function. Loop thru the directory for files and delete them.



Thanks and Regards
Madhu

Vanchi050585, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 2/21/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Hi,

Get the server map path url and get the folder alone. then loop through the below code and delete the files

DirectoryInfo di = new DirectoryInfo("c:/inetpub/wwwroot/demos");
FileInfo[] rgFiles = di.GetFiles("*.aspx");
foreach(FileInfo fi in rgFiles)
{
// Delete the files here
}


Thanks
Karthik
www.f5Debug.net

Vanchi050585, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Amit.Jain on: 3/29/2012 [Member] Starter | Points: 25

Login to post response