By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,973 Members | 1,901 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,973 IT Pros & Developers. It's quick & easy.

Deleting Files from IsolatedStorage

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.