Change a file extension using C# (rename a file)

by Heathesh 1. October 2009 03:13

Only one way

There seems to only be one way to change a file extension in .Net. This is:

string ourPath = @"c:\test.txt";
string newPath = Path.ChangeExtension(ourPath, "bak");
File.Move(ourPath, newPath);

File system entry modified

This apparently doesn't copy the file, only the file system entry is modified which should mean there should be a performance degradation when you do this.

Tags: , , ,

Development | .Net

Powered by BlogEngine.NET 1.5.0.7 (with enhancements by Heathesh)
Theme by Mads Kristensen (with tweeks by Heathesh)

Certifications

Microsoft Certified Professional

Microsoft Certified Technology Specialist

Calendar

<<  September 2010  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

View posts in large calendar