Hi,

Let’s see a simple example of deleting a file in a folder using c#.

using System;
using System.IO;

public class MainClass
{
  static void Main(string[] args)
  {
    FileInfo sampleFile= new FileInfo(@"c:SamplestestFile.txt");

    sampleFile.Create();

    sampleFile.Delete();

  }
}

sampleFile.Create() will create the file in the specified folder.
sampleFile.Delete() will delete the file in the specified folder.

🙂

 

One Comment

  1. Jose June 30, 2011 at 12:36 pm

    Thank you so much for this post. It is really quite frustrating sometimes on how to manage and how to delete file

     

Leave a Reply

Your email address will not be published. Required fields are marked *

 

 

 

Theme by HermesThemes

Copyright © 2018 CoderzHeaven. All Rights Reserved

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.