Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi to all

I added some files into my project under Document folders by coding.

And do some operation based on that file. After that I want to delete that particular

file by program itself. So please guide me to delete that!
Posted
Comments
[no name] 12-Jan-13 4:27am    
please be more clear about your question.

Not sure if I understood the question correctly, but to delete a file, you can use File.Delete[^] method.
 
Share this answer
 
C#
try
    {
        // A.
        // Try to delete the file.
        File.Delete(f);
        return true;
    }
    catch (IOException)
    {
        // B.
        // We couldn't delete the file.
        return false;
    }

for more help

http://www.dotnetperls.com/file-delete[^]
 
Share this answer
 
Use this code:

File.Delete(Server.MapPath("~/YourFolder/" + FileName.Text));


FileName : Image.jpg .....
 
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