I'm trying to figure out a way to navigate to a sub folder in Roaming using C#. I know to access the folder I can use:
string folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
What I'm trying to do is navigate to a folder inside of Roaming, but do not know how. I basically need to do something like this:
string insideroaming = string folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData\FolderName);
Any way to do this? Thanks.
Where “Roaming” is a sub folder of “AppData”. Into that folder might be placed things like default templates, configuration files, and other support data that applications might use that a) might be different for other users of the machine, and b) aren't your actual working documents.
The quick and easy way is to click Start, or the Cortana search icon in Windows 10, type %appdata% , and select the top search result, which should take you to AppData > Roaming.
AppData is a hidden folder located in C:\Users\<username>\AppData. The AppData folder contains custom settings and other information needed by applications. For example, you might find the following in your AppData folder: Web browser bookmarks and cache.
Consider Path.Combine:
string dir = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"FolderName"
);
It returns something similar to:
C:\Users\<UserName>\AppData\Roaming\FolderName
If you need to get a file path inside the folder, you may try
string filePath = Path.Combine(
dir,
"File.txt"
);
or just
string filePath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"FolderName",
"File.txt"
);
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