Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7851689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:14:31+00:00 2026-06-02T19:14:31+00:00

I have created an app that initially creates a database and saves some data

  • 0

I have created an app that initially creates a database and saves some data in it.
Now I want to delete this database and its files when the user clicks on the reset button but I am getting an error – ‘this is use in another process’. I want it to delete and recreate the database when click on the reset button. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T19:14:32+00:00Added an answer on June 2, 2026 at 7:14 pm

    The most frequent cause of this is ude to the thread unsafe nature of interacting with isolated storage on Windows Phone. Regardless of how you’re implementing the database (be it in a file, or series of files), you’re interacting with the isolated storage on some level.

    I highly encourage you to read, and make sure you understand this overview of isolated storage before going too far.

    You’re remark:

    This is in use in another process

    makes me think you’re using a third party library to do your database stuff. This exception/error is being thrown when the library itsself is unable to access isolated storage. Without knowing exactly how you’re implementing the database, it’s hard to be exactly speak to your situation.

    You never “recreate IsolatedStorage”, Isolated Storage is a term used to define the collection of disk space your application has access to. Much like a folder, this disk space has a root, and contains only files that you create.

    In order to avoid thread exceptions when accessing Isolated Storage, make sure you use the using keyword in C# like so:

    namespace IsolatedStorageExample
    {
        public class ISOAccess
        {
            // This example method will read a file inside your Isolated Storage.
            public static String ReadFile(string filename)
            {
                string fileContents = "";
                // Ideally, you should enclose this entire next section in a try/catch block since
                // if there is anything wrong with below, it will crash your app.
                // 
                // This line returns the "handle" to your Isolated Storage. The phone considers the
                // entire isolated storage folder as a single "file", which is why it can be a 
                // little bit of a confusing name.
                using(IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForAppliaction())
                {   
                    // If the file does not exist, return an empty string
                    if(file.Exists(filename))
                    {
                        // Obtain a stream to the file
                        using(IsolatedStorageFileStream stream = File.OpenFile(filename, FileMode.Open)
                        {
                            // Open a stream reader to actually read the file.
                            using(StreamReader reader = new StreamReader(stream))
                            {
                                fileContents = reader.ReadToEnd();
                            }
                        }
                    }   
                }
    
                return fileContents;
            }
        }
    }
    

    That should help with your problem of thread safety. To be more specifically helpful toward what you want to do, take a look at the following methods (you can add this to the above class):

    // BE VERY CAREFUL, running this method will delete *all* the files in isolated storage... ALL OF THEM
    public static void ClearAllIsolatedStorage()
    {
        // get the handle to isolated storage
        using(IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())
        {
            // Get a list of all the folders in the root directory
            Queue<String> rootFolders = new Queue<String>(file.GetDirectoryNames());
    
            // For each folder...
            while(0 != rootFolders.Count)
            {
                string folderName = rootFolders.Dequeue();
    
                // First, recursively delete all the files and folders inside the given folder.
                // This is required, because you cannot delete a non-empty directory
                DeleteFilesInFolderRecursively(file, folderName);
    
                // Now that all of it's contents have been deleted, you can delete the directory
                // itsself.
                file.DeleteDirectory(rootFolders.Dequeue());
            }
    
            // And now we delete all the files in the root directory
            Queue<String> rootFiles = new Queue<String>(file.GetFileNames());
            while(0 != rootFiles.Count)
                file.DeleteFile(rootFiles.Dequeue());
        }
    }
    
    private static void DeleteFilesInFolderRecursively(IsolatedStorageFile iso, string directory)
    {
        // get the folders that are inside this folder
        Queue<string> enclosedDirectories = new Queue<string>(iso.GetDirectoryNames(directory));
    
        // loop through all the folders inside this folder, and recurse on all of them
        while(0 != enclosedDirectories.Count)
        {
            string nextFolderPath = Path.Combine(directory, enclosedDirectories.Dequeue());
            DeleteFilesInFolderRecursively(nextFolderPath);
        }
    
        // This string will allow you to see all the files in this folder.
        string fileSearch = Path.Combine(directory, "*");
    
        // Getting the files in this folder
        Queue<string> filesInDirectory = iso.GetFileNames(fileSearch);
    
        // Finally, deleting all the files in this folder
        while(0 != filesInDirectory.Count)
        {
            iso.DeleteFile(filesInDirectory.Dequeue());
        }
    }
    

    Another thing I highly recommend is implementing the class that accesses IsolatedStorage using a “Multithreaded Singleton Pattern” as described here.

    Hope that’s helpful. Code is provided “as-is”, I have not compiled it, but the general concepts are all there, so if there’s something amiss, read the MSDN docs to see where I goofed. But I assure you, most of this is copied from functional code of mine, so it should work properly with very little fanagaling.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a normal app - initially without cocos2d. Now I need cocos2d
I have a decorator chain that looks like this when initially created: IType calculator
I have created an app that uses NSTimer, which gets triggered each second. My
I have created an iOS app that requires a user to link his/her Dropbox
I have successfully created an app that reads from a bundled .plist file and
I have created a flexible navigation bar in my app that will show custom
I have created a service class for my network connection so that my app
I have created an ashx handler that returns an image to my flex app.
I have several buttons on my app that are being created dynamically. They are
I have a problem regarding Android App. I have created an application that download

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.