Archived:How to get installation drive/path
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.
Article Metadata
Tested with
Devices(s): Nokia N95, Nokia E90
Compatibility
Platform(s): S60 1st Edition, S60 2nd Edition, S60 3rd Edition
Article
Keywords: sys, os
Created: Rafael T.
(10 Dec 2008)
Last edited: hamishwillee
(28 Jun 2012)
Contents |
Overview
Sometimes you need to know where your application is installed so you can create the files and save them into that specific folder. This can be easily done with PySymbian:
First way
# This works for script and SIS
import sys
try:
raise Exception
except Exception:
frame = sys.exc_info()[2].tb_frame
path = frame.f_code.co_filename
print path # prints whole path
print path[:2] # prints the drive
Second way
# This one is better when using SIS packages
import os
print os.getcwd() # prints whole path
print os.getcwd().split("\\")[0] # prints the drive
Conclusion
With this examples you can get the path that your application is installed and do some cool things, like generating a file inside your code and saving to your application's folder. After that, it would be easy to read and edit those files.


28 Sep
2009