The Wagner Blog
Development Notes, News and Trivia









Subscribe to "The Wagner Blog" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.
 

 

Monday, March 17, 2003
 

Craig has a snippet for building paths

I often see people using string concatenation to create directory names. Like this:

string path = "C:\\data\\" + filename;

But there's a much better API:

string path = System.IO.Path.Combine("C:\\data", filename);

Not only does this take care of the whole, "Do I need a trailing slash?" issue, but if you specify an absolute path for the second parameter, it will just return the second parameter. That means that someone can enter "foo" or "C:\\temp\\foo" for filename, and it'll do what you'd expect.

[Craig Andera]


6:04:07 PM    

Chris Frazier "Hydrating a list of ImageLinks from a custom config section" read more
6:02:29 PM    


Click here to visit the Radio UserLand website. © Copyright 2004 Thomas Wagner.
Last update: 5/2/2004; 4:46:05 PM.
This theme is based on the SoundWaves (blue) Manila theme.
March 2003
Sun Mon Tue Wed Thu Fri Sat
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Jan   Apr