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

Comments are closed



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

Answer Questions

 

Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar

http://heathesh.com