So basically I need a string "path" to be something like:
string path = @"C:\Users\CURRENT_USER\file.txt";
How could I do that?
Sincerely,
a guy with an internet connection
So basically I need a string "path" to be something like:
string path = @"C:\Users\CURRENT_USER\file.txt";
How could I do that?
Sincerely,
a guy with an internet connection
Your User profile path stores in
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)
To get specifc file path from that Folder you need to combine it with hard coded string of your file name, like
string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "file.txt")
Output:
Note: Do not forget to add using System.IO
because Path
class is present in System.IO
You can use the Environment.SpecialFolder.UserProfile
enumeration.
string path=Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);