Archived:How to get installation drive/path

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: 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
Platform(s): S60 1st Edition, S60 2nd Edition, S60 3rd Edition
S60 3rd Edition (initial release)
Keywords: sys, os
Created: Rafael T. (10 Dec 2008)
Last edited: hamishwillee (28 Jun 2012)



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
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


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.

This page was last modified on 28 June 2012, at 09:34.
37 page views in the last 30 days.