Click here to Skip to main content
12,630,410 members (28,315 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET
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 11-Jan-13 23:20pm
Comments
onurag19 12-Jan-13 4:27am
   
please be more clear about your question.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Not sure if I understood the question correctly, but to delete a file, you can use File.Delete[^] method.
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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[^]
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

Use this code:

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

FileName : Image.jpg .....
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161205.3 | Last Updated 14 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100