On *nix, ~/foo refers to a file in a user's home directory. On
MSWindows, users normally look at "My Documents" in their home
directory. ISTM that a file that my program would put in ~/. on Linux
should be put in "~/My Documents/" (modulo os.path.normpath()) on
MSWindows, where a user would expect it. How do you guys cope with this
issue?
__________________________________________________ ______________________
TonyN.:' *firstname*nlsnews@georgea*lastname*.com
' <http://www.georgeanelson.com/> 8 2252
Try this:
from win32com.shell import shell, shellcon
HOMEDIR = shell.SHGetSpecialFolderPath(0, shellcon.CSIDL_PERSONAL)
myfile_location = os.path.join(HOMEDIR, myfile_name)
Define a HOMEDIR for your various platforms (use sys.platform to figure
out what choice to make) and the rest of your code should not need to
care where "home" is...
Regards,
jim
Try this:
from win32com.shell import shell, shellcon
HOMEDIR = shell.SHGetSpecialFolderPath(0, shellcon.CSIDL_PERSONAL)
myfile_location = os.path.join(HOMEDIR, myfile_name)
Define a HOMEDIR for your various platforms (use sys.platform to figure
out what choice to make) and the rest of your code should not need to
care where "home" is...
Regards,
jim
In article <11**********************@o13g2000cwo.googlegroups .com>, ji*******@gmail.com wrote: Try this:
from win32com.shell import shell, shellcon HOMEDIR = shell.SHGetSpecialFolderPath(0, shellcon.CSIDL_PERSONAL) myfile_location = os.path.join(HOMEDIR, myfile_name)
Define a HOMEDIR for your various platforms (use sys.platform to figure out what choice to make) and the rest of your code should not need to care where "home" is...
Sounds good, thanks. I'll read up on it all tomorrow.
__________________________________________________ ______________________
TonyN.:' *firstname*nlsnews@georgea*lastname*.com
' <http://www.georgeanelson.com/>
In article <11**********************@o13g2000cwo.googlegroups .com>, ji*******@gmail.com wrote: Try this:
from win32com.shell import shell, shellcon HOMEDIR = shell.SHGetSpecialFolderPath(0, shellcon.CSIDL_PERSONAL) myfile_location = os.path.join(HOMEDIR, myfile_name)
Define a HOMEDIR for your various platforms (use sys.platform to figure out what choice to make) and the rest of your code should not need to care where "home" is...
Sounds good, thanks. I'll read up on it all tomorrow.
__________________________________________________ ______________________
TonyN.:' *firstname*nlsnews@georgea*lastname*.com
' <http://www.georgeanelson.com/>
python import os help(os.path.expanduser) import platform platform.system()
'Windows' platform.release()
'XP'
:-)
Dalius
python import os help(os.path.expanduser) import platform platform.system()
'Windows' platform.release()
'XP'
:-)
Dalius
In article <11**********************@g44g2000cwa.googlegroups .com>, da*****************@gmail.com wrote: python
import os help(os.path.expanduser) import platform platform.system() 'Windows' platform.release() 'XP'
platform looks good.
__________________________________________________ ______________________
TonyN.:' *firstname*nlsnews@georgea*lastname*.com
' <http://www.georgeanelson.com/>
In article <11**********************@g44g2000cwa.googlegroups .com>, da*****************@gmail.com wrote: python
import os help(os.path.expanduser) import platform platform.system() 'Windows' platform.release() 'XP'
platform looks good.
__________________________________________________ ______________________
TonyN.:' *firstname*nlsnews@georgea*lastname*.com
' <http://www.georgeanelson.com/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Grant_S |
last post by:
I need to identify the path to a users "My Document" folder where the
user has a roaming profile and their "My Documents" folder is mapped to
a network share as the H drive (specifically H:\\ -...
|
by: Karl Koscher |
last post by:
I'm trying to communicate with a USB device using C#. I'm able to determine
the device path using P/Invoke and SetupDiGetClassDevs,
SetupDiEnumDeviceInterfaces, and SetupDiGetDeviceInterfaceDetail,...
|
by: JuLiE Dxer |
last post by:
Is there a way via C# to programmatically retrieve the full path name
to folders like "My Documents" ??
I'm seeing examples with the use of Shell32 stuff I believe,
SHGetSpecialFolderLocation...
|
by: Alpha |
last post by:
I use FolderBrowserDlg for user to select a folder path then store it in the
sql table. I then retrieve it to concatenate in a sqlcommand text to retrive
files from that directory but it won't...
|
by: Tom Vogel |
last post by:
Creating a subfolder within my ASP.NET application folder fails with the
above error, but only at my hosting provider. The command:
Directory.CreateDirectory(path)
Path is set to...
|
by: Jonas Auken |
last post by:
hi,
I have a repeater which dynamically loads another usercontrol throught
databinding:
OnClick: DataBind()
rptProduct_ItemDataBound: ViewSmall _viewSmall = (ViewSmall)...
|
by: Clinton Frankland |
last post by:
Hi,
On a Windows 2000 Server when attempting to use
System.IO.Directory.CreateDirectory(string.concat(Server.MapPath(""),
"\verify"))
I receive a System.IO.DirectoryNotFoundException error:...
|
by: Ben |
last post by:
Hello,
I need to save some information into a text file.
For this, I use :
FileOpen(1, "c:\MyFile.txt", OpenMode.Output)
For I = 0 To iCpt - 1
WriteLine(1,...
|
by: Tony Nelson |
last post by:
On *nix, ~/foo refers to a file in a user's home directory. On
MSWindows, users normally look at "My Documents" in their home
directory. ISTM that a file that my program would put in ~/. on Linux...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |