473,395 Members | 1,458 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 2518
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Arran Pearce | last post by:
Hi, I am writing a application and am trying to be good (security wise) and use isolated storage instead of another location on the HDD. My assembly recieves a MemoryStream object then writes...
1
by: Simon Chester | last post by:
Hello! Can anyone help me with this problem?... I have developed an ASP.NET (version 1.1) application which I have deployed to a number of webservers. The web application works fine on Windows...
1
by: Frank Lopez | last post by:
In .NET and C#, is there anyway to create a hook for a specific directory or file where my C# .NET software can monitor which static web files are requested by the browser? What I am doing is...
4
by: greyseal | last post by:
I've gone around and around this thing for the last day or so. Using WIA, I can take and copy images from my Nikon D2H. However, when I attempt to delete the image I find that that capability is...
0
by: Zdenek Drlik | last post by:
Hi, I have an ASP.NET application. I want to use IsolatedStorage in this application. When I run this application with anonymous access set in IIS (user set to IUSR_<machine>) and impersonation...
6
by: Martin Bischoff | last post by:
Hi, I'm creating temporary directories in my web app (e.g. ~/data/temp/temp123) to allow users to upload files. When I later delete these directories (from the code behind), the application...
1
by: ltt19 | last post by:
Hi Does anybody knows hot to Get all directories and files in a HDD. I took a look at System.IO.IsolatedStorage.IsolatedStoregeFile but I could not specify the HDD that i want (for example D: or...
2
by: Bob | last post by:
Hi there, Can anybody offer suggestions on the best approach to overcome this situation: A WinForm app needs to copy files to from an external device to the local drive. When the files are on...
3
by: Kimera.Kimera | last post by:
I'm trying to write a program in VB.net 2003 that basically deletes all files, folders, sub-folders and sub-sub folders (etc). The program is simply for deleting the Windows/Temp folder contents,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.