Expand environment variable for My Documents

后端 未结 6 2141
星月不相逢
星月不相逢 2021-01-04 06:19

I know I can read environment variables like this:

Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

However, it would be r

6条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-04 07:04

    I'm not sure if there is a good way to do this but instead of trying to do environment expansion to get the path why not use the Path.Combine API instead?

    Path.Combine(
      Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
      "Foo");
    

提交回复
热议问题