470,833 Members | 1,346 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,833 developers. It's quick & easy.

Deleting Files from IsolatedStorage

Hi,

I've been having some frustrations with deleting files from the Isolated
Storage directories. Basically, I want my application to remove all
instances of configuration information for my application when the
application is uninstalled. So, I created an uninstaller class that
overrides the uninstall method, as follows:

private void DeleteSettings(){
// Try and delete the settings.config
// created during the saving of user preferences
try {
IsolatedStorageFile isoFile =
IsolatedStorageFile.GetStore(IsolatedStorageScope. User |
IsolatedStorageScope.Assembly, null, null);

String[] dirNames = isoFile.GetDirectoryNames("*");
String[] fileNames = isoFile.GetFileNames("*");

// List the files currently in this Isolated Storage.
// The list represents all users who have personal
// preferences stored for this application.
if (fileNames.Length > 0) {
for (int i = 0; i < fileNames.Length; ++i) {
// Delete the files.
isoFile.DeleteFile(fileNames[i]);
}
// Confirm that no files remain.
fileNames = isoFile.GetFileNames("*");
}
}catch (Exception e) {
MessageBox.Show(e.Message);
}

This was code taken from the MSDN website. When I run this code right after
creating the file in Isolated Storage, it works fine, and the file is
deleted. But when I run this code from the uninstaller class, no files are
returned in the GetFiles("*") method. Is there something else I should be
doing when I'm in the uninstall process?

Thanks
Josh
}
Apr 27 '06 #1
2 2392
Its how you are defining your isolated storage ...

IsolatedStorageFile.GetStore(IsolatedStorageScope. User |
IsolatedStorageScope.Assembly, null, null);

http://msdn2.microsoft.com/en-us/lib...pe(VS.80).aspx

Note that it is being scoped to the assembly .. as such when the uninstall
program runs (from a different assembly) it will not be accessing the same
isolated storage as the application.

This is assuming you are dealing with two seperate assemblies, the other
possibility depending on the setup that you are doing is that the code could
be running in two different user contexts which would also cause the
isolated storage to vary.

Cheers,

Greg

"Josh Kandiko" <Josh Ka*****@discussions.microsoft.com> wrote in message
news:A6**********************************@microsof t.com...
Hi,

I've been having some frustrations with deleting files from the Isolated
Storage directories. Basically, I want my application to remove all
instances of configuration information for my application when the
application is uninstalled. So, I created an uninstaller class that
overrides the uninstall method, as follows:

private void DeleteSettings(){
// Try and delete the settings.config
// created during the saving of user preferences
try {
IsolatedStorageFile isoFile =
IsolatedStorageFile.GetStore(IsolatedStorageScope. User |
IsolatedStorageScope.Assembly, null, null);

String[] dirNames = isoFile.GetDirectoryNames("*");
String[] fileNames = isoFile.GetFileNames("*");

// List the files currently in this Isolated Storage.
// The list represents all users who have personal
// preferences stored for this application.
if (fileNames.Length > 0) {
for (int i = 0; i < fileNames.Length; ++i) {
// Delete the files.
isoFile.DeleteFile(fileNames[i]);
}
// Confirm that no files remain.
fileNames = isoFile.GetFileNames("*");
}
}catch (Exception e) {
MessageBox.Show(e.Message);
}

This was code taken from the MSDN website. When I run this code right
after
creating the file in Isolated Storage, it works fine, and the file is
deleted. But when I run this code from the uninstaller class, no files
are
returned in the GetFiles("*") method. Is there something else I should be
doing when I'm in the uninstall process?

Thanks
Josh
}

Apr 28 '06 #2
Hey, just a thought... Why not add a command line parameter to the
application you are uninstalling that will delete the isolated storage
for you?

Apr 28 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Arran Pearce | last post: by
4 posts views Thread by greyseal | last post: by
reply views Thread by Zdenek Drlik | last post: by
6 posts views Thread by Martin Bischoff | last post: by
1 post views Thread by ltt19 | last post: by
2 posts views Thread by Bob | last post: by
3 posts views Thread by Kimera.Kimera | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.