1

I use the following to get the active Desktop path in Windows:

get_path = os.path.expanduser('~/Desktop/')

And it works. BUT I need this to also work on multilingual environments. Meaning it should work on other languages of Windows. The problem is they have different names for 'Desktop'. To be honest I couldn't test it yet. I don't have a different language Win machine around me. But the program will run on them. So I have to find a way to make it work.

Any advice?

Edit: I found this code for C#:

string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

reference: How to get a path to the desktop for current user in C#?

Perhaps there is a way to integrate this into Python?

shafuq
  • 465
  • 6
  • 20
  • The biggest problem with using `expanduser` is primarily that every "known folder" (a keyword hint for you) in a user's profile is independently relocatable, so its use for saving to known folders is *strictly wrong*. Another problem is that it tends to encourage creating files and directories directly in a user's profile, rather than explicitly using either the local or roaming application data folders, which is inconsistent with platform conventions, possibly very wrong, and generally annoying. – Eryk Sun Feb 07 '18 at 16:47

0 Answers0