Set the Current Working Path
Problem
You want to set the current working directory so you can use relative paths in your code.
Solution
Use the shared Directory.GetCurrentDirectory and Directory.SetCurrentDirectory methods.
Discussion
Relative paths are automatically interpreted in relation to the current working directory. You can retrieve the current working directory by calling Directory.GetCurrentDirectory, or change it using Directory.SetCurrentDirectory. In addition, you can use the shared Path.GetFullPath method to convert a relative path into an absolute path using the current working directory.
Here’s a simple test that demonstrates these concepts:
Console.WriteLine("Using: " & Directory.GetCurrentDirectory()) Console.Write("The relative path ...
Get Microsoft® Visual Basic® .NET Programmer's Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.