java的 System.getProperty("user.home") 在 c#.net 里要怎么写?
巴扎黑
巴扎黑 2017-04-17 15:50:47
0
1
788
巴扎黑
巴扎黑

reply all(1)
Peter_Zhu

The definition of this variable is different in different versions of java.
In java7 and previous versions, the jvm environment variable user.home is defined as the superior directory of the desktop folder in the windows system. The location of desktop is read from HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerShell FoldersDesktop in the registry, and its value is generally %userprofile%desktop. Therefore, its upper-level directory, user.home, is generally mapped to %userprofile%, that is, c:documents and settingsyourusername or c:usersyourusername. This is prone to bugs in win7 that are parsed into the %userprofile% string but not further parsed into a directory path: http://bugs.java.com/view_bug.do?bug_id=4787931.
So this problem has been fixed in java8, and user.home is directly mapped to the system %userprofile% variable, which is usually the user's home directory, that is, c:usersyourusername.
In summary, just treat this variable as the system environment variable userprofile:
Environment.GetEnvironmentVariable("userprofile");
or
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!