SHGetSpecialFolderPath


Paula is mentioning this during her MDC presentations but it's something all Smartphone developers should be aware of...


On Smartphone 2002 you had to store your files withing the \IPSM directory to prevent your files from disappearing upon reboot.  On Smartphone 2003 this was changed to \Storage.  In the next version, there is a good chance that this is going to change one more time (sorry).


So how can you ensure that your application is storing files in a location that doesn't disappear when the device is turned off or the battery goes dead?  Simple: don't hard code paths.


Instead of hard coding paths like \Storage and \IPSM into your application, you should always always always ask the OS where you can safely put files.  This is done by using the SHGetSpecialFolderPath API with the CSIDL_PERSONAL parameter.  Google makes it easy to find VB.NET and C# wrappers for this.


To ensure that your Smartphone applications do the right thing in the future, start using this function in your code today.


[Author: Robert Levy]


Comments (3)

  1. Sudhakar says:

    How to get by default Program Files directory using CFileDialog class

  2. jimmy says:

    I want to create a folder in root directory , can any body tell me the way to do this

    Lets say i want to create the folder in My DocumentTemp .

    Please reply me soon

    Jimmy

  3. Baker says:

    I have come across a similar problem where I cannot create or store into a file using WM 2003 SE. The directory just doesnt seem to have the file one I run javascript to create it.

    No website has any guidance or help on this topic. Any help will be extremely appreciated.

    Thankyou,

    Baker

Skip to main content