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

 

Tag cloud

Calendar

<<  July 2017  >>
MoTuWeThFrSaSu
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

View posts in large calendar

http://heathesh.com