How can i get the path of the current user's Application Data folder?
Look at combining Environment.GetFolderPath and Environment.SpecialFolder to do this.
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
how to get users' application data folder using C#?
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
How to get Application Data folder path programmatically in C#?
This will get the directory of the ApplicationData
folder (or any other special system folder):
var appDataPath
= Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
VBA How to get path to The Current Users Application data folder?
You can use Environ("AppData")
to get this path. Environ will pull any system variable, which can be found by using the set
command at the DOS prompt.
How can I get the path to the %APPDATA% directory in Python?
import os
print os.getenv('APPDATA')
C++ : How to get actual folder path when the path has special folder names
The Win32 API that expands environment variable references of the form %variable%
in strings is ExpandEnvironnmentStrings.
C# getting the path of %AppData%
To get the AppData directory, it's best to use the GetFolderPath
method:
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
(must add using System
if not present).
%AppData%
is an environment variable, and they are not automatically expanded anywhere in .NET, although you can explicitly use the Environment.ExpandEnvironmentVariable
method to do so. I would still strongly suggest that you use GetFolderPath
however, because as Johannes Rössel points out in the comment, %AppData%
may not be set in certain circumstances.
Finally, to create the path as shown in your example:
var fileName = Path.Combine(Environment.GetFolderPath(
Environment.SpecialFolder.ApplicationData), "DateLinks.xml");
Related Topics
How to Embed Multiple Images in Email Body Using .Net
C# Winforms: How to Set Main Function Stathreadattribute
Overloaded Method-Group Argument Confuses Overload Resolution
Converting ASP.NET MVC Razor @Helper Function into a Method of a Helper Class
Queuing in Oneway Wcf Messages Using Windows Service and SQL Server
How to Use Npm with ASP.NET Core
How to Pass Parameters to Activator.Createinstance<T>()
Generic List - Moving an Item Within the List
How to List All Sub Directories in a Directory
How to Resize Image in C# Winrt/Winmd
Windows Forms Graphic Issue on Windows 10 Os
Generate 16-Bit Grayscale Bitmapdata and Save to File
Sending an Array of Values to Oracle Procedure to Use in Where in Clause