I'm writing a Windows program that needs to store some user files.
The logical place to store them is in "Applicatio n Data", right?
Is there a good way to find the correct location of that directory,
preferably without any C extensions? It's ok if the directory is
found at installation time rather than runtime, and bdist_wininst does
have a way to find it from a post-installation script. The trouble is
that the post-installation script doesn't seem to have an obvious way
to communicate the info to the application for later use!
Any suggestions?
Thanks. 7 11823
[Paul Rubin wrote] I'm writing a Windows program that needs to store some user files.
The logical place to store them is in "Applicatio n Data", right?
Is there a good way to find the correct location of that directory, preferably without any C extensions? It's ok if the directory is found at installation time rather than runtime, and bdist_wininst does have a way to find it from a post-installation script. The trouble is that the post-installation script doesn't seem to have an obvious way to communicate the info to the application for later use!
Any suggestions?
The canonical way is using the Window API SHGetFolderPath function with
the CSIDL_APPDATA key:
from win32com.shell import shellcon, shell
print shell.SHGetFold erPath(0, shellcon.CSIDL_ APPDATA, 0, 0)
This requires the PyWin32 extensions (which you already have if you have
ActivePython installed).
Alternatively you could write your own little C extension to call this
Window API function... but you didn't want to do that. You can also call
this WIndows API function (in the shell32.dll) with the Python "ctypes"
modules out there.
Trent
--
Trent Mick Tr****@ActiveSt ate.com
You have the environment variable APPDATA. You can access it with
os.environ().
"Rune Strand" <ru*********@gm ail.com> writes: You have the environment variable APPDATA. You can access it with os.environ().
Thanks!!!!!! Wow, I'd been hacking away at much messier approaches
than that. It's actually os.environ['APPDATA'] ;-)
I had a post yesterday on just that. Anyways, I always love it when
what can be a really annoying problem, reduces into as something simple
and elegant like a python dict. (in general, I find dictionaries
rock).
I remember a similar eureka, when some time ago I found it really neat
that split w/no args works on whitespace words. Or, things like min and
sort actually travel down levels of data structures for you. Or, when
one realizes things like "in" works on all sorts of sequences even
filehandes, or you can treat gzipped files just like normal files, or
coolness of cStringIO, or startswith and endsmith methods on strings,
or . . .
Hmm, I wonder if there is a page of the little python coolnesses. I
recall one of python annoyances.
john
[Paul Rubin wrote] "Rune Strand" <ru*********@gm ail.com> writes: You have the environment variable APPDATA. You can access it with os.environ().
Thanks!!!!!! Wow, I'd been hacking away at much messier approaches than that. It's actually os.environ['APPDATA'] ;-)
Note that the APPDATA environment variable is only there on *some* of
the Windows flavours. It is there on Win2k and WinXP. It is not there on
WinME. Dunno about Win95, Win98, WinNT... but you may not care about
those old guys.
Cheers,
Trent
--
Trent Mick Tr****@ActiveSt ate.com
Trent Mick ha scritto: Note that the APPDATA environment variable is only there on *some* of the Windows flavours. It is there on Win2k and WinXP. It is not there on WinME. Dunno about Win95, Win98, WinNT... but you may not care about those old guys.
That's (I guess) because the DOS spawn (win9x family) was single user
and did not really have concepts like home directories, profiles,
separate settings for each user... hell, it did not even have users! :-D
--
Renato
--------------------------------
Usi Fedora? Fai un salto da noi: http://www.fedoraitalia.org
On 28 Jun 2005 21:09:12 -0700, Paul Rubin <http://ph****@NOSPAM.i nvalid> wrote: "Rune Strand" <ru*********@gm ail.com> writes: You have the environment variable APPDATA. You can access it with os.environ().
Thanks!!!!!! Wow, I'd been hacking away at much messier approaches than that. It's actually os.environ['APPDATA'] ;-)
Hm, which windows is that? Not NT4 ;-)
Regards,
Bengt Richter This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: JohnD |
last post by:
I am using XP Pro and when I try and run an ASP.NET page on my own server I recieve the following error messag
Server cannot access application directory ..(web directory here)... The directory does not exist or is not accessible because of security settings.
The link below this line is attached to a microsoft knowledge base article that addresses this issue, but I can not seem to make the resoultion work in windows XP Pro. Particularly I...
|
by: 21novembre |
last post by:
Hi all,
I made a question several days before to describe my strange trouble of
mysqldump. But I still can't figour it out. Well, I just want to ask
another question whether I could just backup my databases by copying
the data folder to some place? Then if I meet some disaster, could I
just copy the backup folder back to recover my databases?
Thank you.
Zh.y
|
by: Rajat Tandon |
last post by:
Hello Everybody,
Please guide me so that I can fulfill this challenging assisnment ...
I have been asked to "Restructure a Windows application" from scratch in 2
months. The existing application which is working but it is very heavy as no
proper application architecture and layering has been followed for this. It
was really hard to maintain (as I was maintaing it till now) .
First let me tell u a bit about my application ...
|
by: z. f. |
last post by:
Hi,
I'm working on a web project and i create classes to do business logic and
connect to DB.
i also need a windows application to do the same functionality as defined
in classes inside the ASP.NET project.
when i reference the web project DLL (inside the BIN directory) I
successfully make a call to a function and get return value.
but this is just a test and when trying to access the application
|
by: Alex Maghen |
last post by:
Hi. I had previously installed VS2005 beta 1. I carefully followed all the
steps (I thought) to deinstall it and then installed beta 2. According to the
documentation, the "Data" directory which was to be a "special" directory in
the docroot of an ASP.NET app, has been renamed to "app_data". That's a GOOD
thing because you guys were using up too many normal words for reserved
purposes. Anyway, the problem is that I have a "Data" directory...
| |
by: Simon Verona |
last post by:
I have a windows forms application that I wish to build an installer for.
Part of this application is an .asp webpage that I wish to install alongside
the windows application and create a virtual directory for.
I know how to build a windows installer, and also how to build a web
installer that will create the virtual directory and install the asp file.
However, I can't work out how to create a single installer that will install
the...
|
by: MrSpock |
last post by:
1. Create a new Windows Application project.
2. Open the project properties and check "Make single instance application".
3. Build.
4. Go to the release folder and run the application.
5. Try to open a second instance of the application.
This will cause an unhandled exception and the "Send Error Report" box shows
up. Does this happen to anyone else, or is it just me?
Debug info: "Unhandled exception at 0x00e149fd in...
|
by: Matthias Wohlmann |
last post by:
Hi,
I'm getting the following error when trying to start my application
using Internet Explorer:
"Server cannot access application directory D:\xxx. The directory does
not exist or is not accessible because of security settings."
In IIS I have set Directory Security for my application to allow
Anonymous access (using IUSR_<Server>) and Integrated Windows
authentication.
In the web.config i have set impersonation="true" userName="test"....
|
by: Chad A. Beckner |
last post by:
Hi everyone,
I have a common class library (call it common_library) that I
include/reference in my projects. In this class library, I would like to
have it save certain settings to the user.config for the application.
However, when I put in
Properties.Settings.Default = somevalue;
it kicks back an exception
|
by: ilangovan |
last post by:
Hai friends,
I have a problem in my windows application which contains about 11000
lines. For this application, i download the tabcontrols from the net. An error which has the name of 'encounter problem' occurs when i rapidly change the tabs in my application. and also in the solution coding an error occurs as
' "Error Creating Windows Handle' as 'Win32 unhandled exception is unhandled'
so please tell the solution for this problem...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |