1

I'm having a problem with Windows 7 paths that can really be used to launch files etc, for example

"C:\Users\mattias\My Pictures\manual.pdf"

the actual location is

"c:\Users\mattias\Documents\My Pictures\manual.pdf"

This is probably because Windows 7 uses libraries, but I need a good way to resolve these kinds of paths to the actual path. I could hack something together Environment.SpecialFolder but it doesn't seem like a good solution since it doesnt take the user into account, The solution should also work under Vista. Do I have to mess around with the Windows API Code Pack and check windows versions or is there a better solution=

Homde
  • 4,246
  • 4
  • 34
  • 50

1 Answers1

3

This should get you the actual path:

Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);

Just change the MyPictures if you need a different location.

Bali C
  • 30,582
  • 35
  • 123
  • 152
  • As I said, I can probably hack together something with Environment.Specialfolder but it doesn't seem like a really good solution since it'll be hard to cover all scenarios – Homde Feb 03 '12 at 12:17
  • I don't see what the issue with `SpecialFolder` is. It gets the drive, username and directory for you, what could be easier? – Bali C Feb 03 '12 at 12:18
  • You'd need to check each path and see if it's legal and manipulate it differently depending on what directory they're trying to access, I want something like GetRealPath(path) – Homde Feb 03 '12 at 12:21