Sponsored Ad

Sunday, March 13, 2011

How to change extension of a file using C# Program

This program will help you to change a file extension using C# code. C# provide a inbuilt method ChangeExtension to change the file extension.

As you can see in the output, the file have different extension.

image

using System;
using System.IO;
namespace MyApp
{
    class Extension_class
    {
        static void Main()
        {
            string myPath = Path.ChangeExtension(@"D:\my_file.txt", "bat");

            Console.WriteLine(myPath); 
            Console.Read();
        }
    }
}

No comments:

Post a Comment

Sponsored Ad

Development Updates