Expand My Documents?

  • Thread starter Thread starter Zeke
  • Start date Start date
Z

Zeke

I would like to keep the name of My Documents in an ini file in the shape
"%mydocuments%" or similar and then treat it like e.g. "%appdata%" with
Environment.ExpandEnvironmentVariables() or something similar. How would I
do that, and get it right also if My Documents is relocated?
 
Hi Zeke,

Why not just use %mydocuments% inside your ini.file and just string.replace it with Environment.SpecialFolder.Personal when you need it, or evenbetter, use %Personal% instead as you could then just cast it to the proper Environment.SpecialFolder after removing the %.

string path = Environment.GetFolderPath( (Environment.SpecialFolder)Enum.Parse( typeof(Environment.SpecialFolder), "Personal") ) );
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top