Overview
- Provides helper methods for working with file system paths as strings.
Examples
Change Extensions
// This does NOT rename the file! It is only a string operation.
Console.WriteLine(Path.ChangeExtension(@"C:\Public\Test.txt", ".doc"));
Combine Paths
string root = @"C:\Public\Test";
string subdir = @"Subtest\";
string combined = Path.Combine(root, subdir);
Console.WriteLine(combined);
// Without the trailing backslash on Subtest\ this would give
// C:\Public\Test instead of C:\Public\Test\Subtest
Console.WriteLine(Path.GetDirectoryName(combined));
Random File Names
Console.WriteLine(Path.ChangeExtension(Path.GetRandomFileName(), ".txt"));
You May Also Like

Exam 70-536 Study Notes
My study notes for Microsoft exam 70-536: .NET types, collections, generics, I/O, serialization and more, with C# examples.

Starting Exam 70-536 Study
After a burnout, I'm putting my own project on hold to study for Microsoft exam 70-536.

Design Patterns - Proxy Pattern
The Proxy Pattern, and the last article in the design patterns series, now that I've finished reading Head First Design Patterns.




