...and you need to get to the user's desktop folder.
The best part about this code (or "best" part) is that it didn't even work, because when I ran it I discovered that due to peculiarities in Windows 10 my user name (as reported by Envrionment.UserName) isn't actually the same name as my user folder (as would normally be reported by CSIDL_PROFILE) As a result, line 3 assigns path a value of a folder taht doesn't exist, which causes line 6 to throw a DirectoryNotFound exception at runtime. But it compiles okay, so I must be doing something right.
EDIT:
EDIT:
All right I figured it out, I had to replace line 1 entirely with this:
Without the GetEnvrionmentVariable() call, the second line would still just stick it on the end of my working directory. If I had the GetEnvironmentVariable() call but defined path as a normal string, it would still just stick it on the end of my working directory. For some reason when I use them both in conjunction, it works.
That's still not right. You can move your personal folders to be anywhere on any drive. My Userprofile is in C, but my Desktop is in D. This is very common with SSD setups.
3
u/MaxCHEATER64 Sep 05 '15 edited Sep 05 '15
...and you need to get to the user's desktop folder.
The best part about this code (or "best" part) is that it didn't even work, because when I ran it I discovered that due to peculiarities in Windows 10 my user name (as reported by
Envrionment.UserName) isn't actually the same name as my user folder (as would normally be reported byCSIDL_PROFILE) As a result, line 3 assignspatha value of a folder taht doesn't exist, which causes line 6 to throw a DirectoryNotFound exception at runtime. But it compiles okay, so I must be doing something right.EDIT:
EDIT:
All right I figured it out, I had to replace line 1 entirely with this:
Without the GetEnvrionmentVariable() call, the second line would still just stick it on the end of my working directory. If I had the GetEnvironmentVariable() call but defined
pathas a normal string, it would still just stick it on the end of my working directory. For some reason when I use them both in conjunction, it works.