Skip to content

Instantly share code, notes, and snippets.

@songzheng45
Last active December 23, 2023 23:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save songzheng45/8a7a2ff6fbb62f000ecc87e888fc4c46 to your computer and use it in GitHub Desktop.
Save songzheng45/8a7a2ff6fbb62f000ecc87e888fc4c46 to your computer and use it in GitHub Desktop.
C# - get user profile folder
using System.IO;


string userProfile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
// output : C:\Users\robin

string myDocuments = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
// output : C:\Users\robin\Documents
// 依次类推可以得到 Music Videos 等文件夹
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment