Function for getting localized path?

孤人 提交于 2019-11-29 10:41:07
Anders

SHGetLocalizedName(). There is a PInvoke sample on Michael Kaplan's blog.

I'm pretty sure there isn't a function to transform a path to its localized form because when you see the bigger picture it doesn't make sense. If you have a roaming profile there might not even be a "Users" or "Benutzer" folder because it would all be wherever the server admin put it.

It also begs the question of how you call this function. For the sake of argument we'll just assume that you call it with the US English defaults. If you say "give me the German localized version of c:\Users\Bob", Vista and Windows 7 will be fine with this but XP doesn't know about the "Users" folder. So that would break without a backwards patch that you can't guarantee would be installed.

Generally Microsoft recommends not even worrying about the left half of a path. Instead you're just supposed to use Environment.GetFolderPath() and pass it one of the SpecialFolder enumerations. Anything after the special folder part is yours to define and create but that's it. Your code should say, "relative to the desktop create a folder called Bob". Whatever that resolves to should never be stored because its possible for that path to change some day,

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!