Hack Forums
[C#] Windows 10 C# Appdata Path - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] Windows 10 C# Appdata Path (/showthread.php?tid=4928807)



Windows 10 C# Appdata Path - mrnikbobjeff - Jul 30, 2015

Hey HF,
I updated my System to Windows 10 yesterday, which resulted in several of my own applications not working, which I tracked down to the Path finding tools which c# offers, such as
Code
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)
Windows does not return anything for this, thus I wanted to ask if anybody already has found a solution for this.
many thanks


* - Sleeping With Sirens - Jul 30, 2015

Code
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

[Image: FObOORf.png]


* - He B TeMy - Jul 30, 2015

(Jul 30, 2015 10:22 AM)Sleeping With Sirens Wrote:  
Code
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

[Image: FObOORf.png]

That's not what OP asked.
I don't have w10


* - rezzex - Jul 30, 2015

[Image: BQujHED.png]
I get the right Path.
[Image: sQ9UGrj.png]


* - n0$f3ratu$ - Jul 30, 2015

(Jul 30, 2015 10:21 AM)mrnikbobjeff Wrote:  Hey HF,
I updated my System to Windows 10 yesterday, which resulted in several of my own applications not working, which I tracked down to the Path finding tools which c# offers, such as
Code
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)
Windows does not return anything for this, thus I wanted to ask if anybody already has found a solution for this.
many thanks

Use
Code
Environment.ExpandEnvironmentVariables("%USERPROFILE%")



* - Assault - Jul 30, 2015

(Jul 30, 2015 11:55 AM)n0$f3ratu$ Wrote:  Use
Code
Environment.ExpandEnvironmentVariables("%USERPROFILE%")

no, this is a horrible solution.
Stick w/ GetFolderPath()


* - pille - Jul 31, 2015

string s = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
Console.WriteLine("{0} {1}", "Appdata Path:", s,);
Console.ReadLine();
////
result:
Appdata Path: C:\Users\Jason\AppData\Roaming


* - He B TeMy - Jul 31, 2015

post above, that doesn't compile.


* - Odus - Jul 31, 2015

(Jul 31, 2015 09:21 AM)pille Wrote:  
Code
Console.WriteLine("{0} {1}", "Appdata Path:", s,);

v

Code
Console.WriteLine("AppData path: {0}", s);

?


* - mrnikbobjeff - Jul 31, 2015

Thanks for all this help, it seems to be related to the issue described hereRyuJIT problemsThanks for the help, the functions work as expected but in release mode wrong arguments were passed.
/Closed


* - He B TeMy - Jul 31, 2015

Yea, i saw it a couple days ago, pretty fucked up bug, that's why you want before using new software, especially entire frameworks and OS's.

If you're sure that's it, you can always downgrade to .net 4.5, don't check optimizations, disable RyuJIT or wait for a fix, which won't take long since the bug was already reported couple days ago.

But you already now that... so.


* - salmoneus - Jul 31, 2015

(Jul 30, 2015 10:45 PM)Assault Wrote:  no, this is a horrible solution.
Stick w/ GetFolderPath()

LUlz, one queries registry and one queries environment block. difference is negligible so shut the fuck up


* - He B TeMy - Jul 31, 2015

(Jul 31, 2015 01:39 PM)salmoneus Wrote:  LUlz, one queries registry and one queries environment block. difference is negligible so shut the fuck up

Environment block? LOL.

The difference is DIFFERENT because one uses WinAPI which is reliable, the other one uses Environment variables which can be CHANGED.


* - salmoneus - Jul 31, 2015

(Jul 31, 2015 05:46 PM)He B TeMy Wrote:  Environment block? LOL.

The difference is DIFFERENT because one uses WinAPI which is reliable, the other one uses Environment variables which can be CHANGED.

ur fucking stupid they both use winapi just goes to show ur lack of understanding lol
who the fuck is going to change the userprofile variable??

call chain:
[Image: agE637l.png]
[Image: EpCGyvV.png]
sources: http://reflector.webtropy.com/default.aspx/4@0/4@0/DEVDIV_TFS/Dev10/Releases/RTMRel/ndp/clr/src/BCL/System/Environment@cs/1305376/Environment@cs

& corresponding reactos files

http://stackoverflow.com/questions/28376922/what-is-rtlqueryenvironmentvariable-for <<<< to educate you ???

now let's see the other:
[Image: 26qLQb9.png]
--->
http://doxygen.reactos.org/d6/d63/shellpath_8c_a7a28d98f8ebdd7634ba70c365c4ab36d.html#a7a28d98f8ebdd7634ba70c365c4ab36d

u fucking cheeky cunt thinking you know shit GOOD GOD THIS PLACE IS A CESSPOOL OF NARCISSISM

[Image: 1kKldf5.png]


* - He B TeMy - Aug 1, 2015

(Jul 31, 2015 06:26 PM)salmoneus Wrote:  ur fucking stupid they both use winapi just goes to show ur lack of understanding lol
who the fuck is going to change the userprofile variable??

call chain:
[Image: agE637l.png]
[Image: EpCGyvV.png]
sources: http://reflector.webtropy.com/default.aspx/4@0/4@0/DEVDIV_TFS/Dev10/Releases/RTMRel/ndp/clr/src/BCL/System/Environment@cs/1305376/Environment@cs

& corresponding reactos files

http://stackoverflow.com/questions/28376922/what-is-rtlqueryenvironmentvariable-for <<<< to educate you ???

now let's see the other:
[Image: 26qLQb9.png]
--->
http://doxygen.reactos.org/d6/d63/shellpath_8c_a7a28d98f8ebdd7634ba70c365c4ab36d.html#a7a28d98f8ebdd7634ba70c365c4ab36d

u fucking cheeky cunt thinking you know shit GOOD GOD THIS PLACE IS A CESSPOOL OF NARCISSISM

[Image: 1kKldf5.png]

Shut the fuck up you fucking idiot, you don't use environment variables if there's a more reliable and consistent way to get them.

This place is a chesspool of fucking moron's like you you piece of shit.
All that crap in one post just to prove what? You're still the same arrogant kid.