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

<<  May 2017  >>
MoTuWeThFrSaSu
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

View posts in large calendar

http://heathesh.com