Click here to Skip to main content
15,898,939 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
see i am not using the static path.
i want to delete the file which has relative path.
for example
"~/student_image/student_photo/j.jpg"

got it or you need more specification.
Posted

You can get the physical path with Page.MapPath.

Nick
 
Share this answer
 
Following code will help you .....

C#
try {
FileInfo myFile= new FileInfo(MapPath(".") + "\\" + yourfilename);
if (myFile.Exists) {
File.Delete(MapPath(".") + "\\" + yourfilename);
}
else {
throw new FileNotFoundException();
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900