G
Guest
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);
}
// 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
}
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);
}
// 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
}