MCTS Book Error

by Brad 22. May 2007 14:58

When i decided to take the long and winding road to MCTS glory i read a couple of reviews on the Textbooks available to help me. As they're weren't many books at the time i went for:

Microsoft .NET Framework 2.0 Application Development Foundation - Self-Paced Training Kit.

In the main its a good book, with both C# and VB code examples, however the reviews on amazon said there were a few errors in it... and well i've found the first!

Page 78 says:

How to change a file extension:

string ourPath = @"c:\boot.ini";
Console.WriteLine("Ext : {0}", Path
.GetExtension(ourPath));
Console.WriteLine("Change Path: {0} ", Path.ChangeExtension(ourPath, "bak"));

From that you might assume that  Path.ChangeExtension() would change the path, but infact all it does it return a string of the new filename. To actually change the extension you need to do the following:

File

.Move(ourPath, Path.ChangeExtension(ourPath, "bak"));

string

Tags:

C#

Powered by BlogEngine.NET 1.5.0.7
Theme by Interakting

Interakting

A full service digital agency offering online strategy, design and usability, systems integration and online marketing services that deliver real business benefits and ensure your online objectives are met.

Calendar

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

View posts in large calendar