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 7581883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:18:11+00:00 2026-05-30T18:18:11+00:00

I am trying to read a text file from IsolatedStorage and check it contains

  • 0

I am trying to read a text file from IsolatedStorage and check it contains a string. If not, the string is added to the end of the file. But When I am trying to write the string into file I got an error: "Operation not permitted on IsolatedStorageFileStream.". My code shown below. How can I overcome this problem?

public void AddToDownloadList()
{
    IsolatedStorageFile downloadFile=IsolatedStorageFile.GetUserStoreForApplication();

    try
    {
        string downloads = string.Empty;

        if (!downloadFile.DirectoryExists("DownloadedFiles"))
            downloadFile.CreateDirectory( "DownloadedFiles" );

        if(downloadFile.FileExists("DownloadedFiles\\DownloadList.txt"))
        {
            IsolatedStorageFileStream downloadStream = downloadFile.OpenFile("DownloadedFiles\\DownloadList.txt",FileMode.Open, FileAccess.Read );

            using ( StreamReader reader = new StreamReader( downloadStream ) )
            {
                downloads = reader.ReadToEnd();
                reader.Close();
            }
            downloadFile.DeleteFile( "DownloadedFiles\\DownloadList.txt" );
        }

        downloadFile.CreateFile( "DownloadedFiles\\DownloadList.txt" );

        string currentFile = FileName;

        if ( !downloads.Contains( currentFile ) )
        {
            downloads += currentFile;

            using ( StreamWriter writeFile = new StreamWriter( new IsolatedStorageFileStream( "DownloadedFiles\\DownloadList.txt", FileMode.Create, FileAccess.Write, downloadFile ) ) )
            {
                writeFile.Write( currentFile + "," );
                writeFile.Close();
            }
        }
   }

   catch ( Exception ex )
   {
       string message = ex.Message;
   }
}
  • 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-05-30T18:18:12+00:00Added an answer on May 30, 2026 at 6:18 pm

    I think the problem you were having has to do with the line where you create the StreamWriter by newing up the IsolatedStorageFileStream – when you already should have the right one from the return of the downloadFile.CreateFile() call.

    Try this code, I think it does what you want to do:

    public static void AddToDownloadList()
    {
        try
        {
            AddToDownloadList("DownloadedFiles", "this file name", "DownloadedFiles\\DownloadList.txt");
        }
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine("Exception: " + ex.Message);
        }
    }
    
    public static void AddToDownloadList(string directory, string fileName, string filePath)
    {
        string downloads = string.Empty;
        using (IsolatedStorageFile downloadFile = IsolatedStorageFile.GetUserStoreForApplication())
        {
            if (!downloadFile.DirectoryExists(directory))
                downloadFile.CreateDirectory(directory);
    
    
        if (downloadFile.FileExists(filePath))
            {
                IsolatedStorageFileStream downloadStream = downloadFile.OpenFile(filePath, FileMode.Open, FileAccess.Read);
                using (StreamReader reader = new StreamReader(downloadStream))
                {
                    downloads = reader.ReadToEnd();
                    reader.Close();
                }
            }
    
            string currentFile = fileName;
            if (!downloads.Contains(currentFile))
            {
                downloadFile.DeleteFile(filePath);
                using (IsolatedStorageFileStream stream = downloadFile.CreateFile(filePath))
                {
    
                    downloads += currentFile;
                    using (StreamWriter writeFile = new StreamWriter(stream))
                    {
                        writeFile.Write(currentFile + ",");
                        writeFile.Close();
                    }
    
                }
            }
        }
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, I'm trying to read from a text file and store each line into
I'm trying to read data from a text file, clear it, and then write
I Im trying to read from one text file and write to another one.
I am trying to read some info from a text file by using windows
I am trying to read values from a text file using the Qt code
I'm trying to read a list of items from a text file and format
I am trying to read in a text input file that contains a list
I request a text file from a server. The url does not end in
Hi I am trying to read a plain text file named test.txt from my
I am trying to read floating point numbers from a file into a dynamically

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.