Syntax:
public static string ChangeExtension(
string path,
string extension
)
Example:
using System;
using System.IO;
public class CPath{
public static void Main() {
string file1 = @"C:\mydir\myfile.com.extension";
string file2 = @"C:\mydir\";
string result;
result = Path.ChangeExtension(file1, ".old");
// result will conatin 'C:\mydir\myfile.com.old'
result = Path.ChangeExtension(file1, "");
// result will conatin 'C:\mydir\myfile.com.' //If you don’t specify an extension, the current extension is remove
result = Path.ChangeExtension(file2, ".old");
// result will contain 'C:\mydir\.old'
} }
|