DAaaMan64 Posted December 21, 2009 Share Posted December 21, 2009 So I redirected My Documents folder in Win 7. To D:\. Now I want to get the My Documents folder in a C# app and in the C++ game, I want to get the same file in the same My Documents folder. So I'm doing this: C++: SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_DEFAULT, path); And I get: path = "C:\Users\DAaaMan64\Documents" C#: string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal); And I get: path = "D:\\" ^^ that is the redirected My Documents folder. As far as I'm concerned this is a bug. I'm about ready to just pipe it to the child process. Anyone got an ideas? Thanks. Link to comment Share on other sites More sharing options...
0 hdood Posted December 21, 2009 Share Posted December 21, 2009 Have you tried asking for SHGFP_TYPE_CURRENT instead? At the moment you appear to be asking for the default location, rather than the current one. Link to comment Share on other sites More sharing options...
0 DAaaMan64 Posted December 21, 2009 Author Share Posted December 21, 2009 Have you tried asking for SHGFP_TYPE_CURRENT instead? At the moment you appear to be asking for the default location, rather than the current one. That was a the solution. Thank you :) Link to comment Share on other sites More sharing options...
0 boogerjones Posted December 21, 2009 Share Posted December 21, 2009 Also notice that Environment.GetFolderPath() does a P/Invoke to SHGetFolderPath with the TYPE flag always set to SHGFP_TYPE_CURRENT (0). Further, the SHGetFolderPath function has been replaced by SHGetKnownFolderPath, which allows an expanded set of options. Glad things are working. Link to comment Share on other sites More sharing options...
0 hdood Posted December 21, 2009 Share Posted December 21, 2009 Further, the SHGetFolderPath function has been replaced by SHGetKnownFolderPath, which allows an expanded set of options. The only problem with that is that it's new in Vista, meaning you'll have to check the OS version and then conditionally call either it or SHGetFolderPath depending on the version. Normally not worth it. Link to comment Share on other sites More sharing options...
Question
DAaaMan64
So I redirected My Documents folder in Win 7. To D:\.
Now I want to get the My Documents folder in a C# app and in the C++ game, I want to get the same file in the same My Documents folder. So I'm doing this:
C++:
And I get: path = "C:\Users\DAaaMan64\Documents"
C#:
And I get: path = "D:\\"
^^ that is the redirected My Documents folder.
As far as I'm concerned this is a bug.
I'm about ready to just pipe it to the child process. Anyone got an ideas?
Thanks.
Link to comment
Share on other sites
4 answers to this question
Recommended Posts