In C++ it's not too hard to get the full pathname to the folder that the shell calls "My Documents" in Windows XP and Windows 7 and "Documents" in Vista; see Get path to My Documents
Is there a simple way to do this in Python?
Click the Start button and then click Computer, click to open the location of the desired file, hold down the Shift key and right-click the file. Copy As Path: Click this option to paste the full file path into a document. Properties: Click this option to immediately view the full file path (location).
The Public folder is located in "C:\Users\Public", in all Windows versions. All user accounts registered in Windows have access to it. That's why it is named Public.
Browsing to the Documents folder in Windows Explorer Open My Computer. Double-click the C: drive. In the C: drive, double-click the Documents and Settings folder. In Documents and Settings, double-click the folder for the users My Documents you want to see.
The document directory is used by the system to save document files, picture files, report files and other files that are not a part of the database.
You could use the ctypes module to get the "My Documents" directory:
import ctypes
from ctypes.wintypes import MAX_PATH
dll = ctypes.windll.shell32
buf = ctypes.create_unicode_buffer(MAX_PATH + 1)
if dll.SHGetSpecialFolderPathW(None, buf, 0x0005, False):
print(buf.value)
else:
print("Failure!")
Source: http://bugs.python.org/issue1763#msg62242
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With