In the .NET base class library there is a class System.IO.Path for doing common operations on strings representing a file system path. However, what I need is a class that encapsulates a path instead, so I get type-safety and a possibly shorter notation of path operations. I'm thinking of a .NET equivalent of C++ Boost's path class. Does such a class exist?
Update: I'm not necessarily looking for a class that can hold both file and directory paths. However, as a file system path can be used for pointing to both, I find it obvious that same class can be used.
Conclusion: DirectoryInfo and FileInfo come close to what I'm looking for. However, they seem to be intended as a representation of a file or directory, rather than a file or directory path. This makes it difficult to do path operations, such as combining a directory path and a relative file path, so I think I'll write a class that encapsulates a path.
You are looking for the System.IO.DirectoryInfo
class.
The DirectoryInfo
class derives from the abstract [FileSystemInfo]
class and you also have the FileInfo
class that describes files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With