In C#, you can use the Path
class from the System.IO
namespace to work with file and directory paths. To get the full path of a directory, you can use the Path.GetFullPath()
method, passing the directory path as the parameter. Here's an example:
main.cs166 chars7 lines
Output:
main.cs30 chars2 lines
The GetFullPath()
method resolves any relative path components in the specified path and returns the absolute path, which includes the drive letter, root folder, and any intermediate folders. If the directory path does not exist, the method will throw an exception. You can use the Directory.Exists()
method to check if the directory exists before getting its full path.
gistlibby LogSnag