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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:09:31+00:00 2026-06-10T07:09:31+00:00

I have a folder called data/ in my project that contains txt files .

  • 0

I have a folder called data/ in my project that contains txt files.

I configured Build Action to resources to all files.

I tried these different ways:

method 1

var resource = Application.GetResourceStream(new Uri(fName, UriKind.Relative));
StreamReader streamReader = new StreamReader(resource.Stream);
Debug.WriteLine(streamReader.ReadToEnd());

method 2

IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
string[] fileNames = myIsolatedStorage.GetFileNames("*.txt");

method 3

using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
{
   using (StreamReader fileReader = new StreamReader(new IsolatedStorageFileStream(fName, FileMode.Open, isf)))
   {
      while (!fileReader.EndOfStream)
      {
        string line = fileReader.ReadLine();
        al.Add(line);
        Debug.WriteLine(line);
      }
   }
}

Now, i tried different ways to read files without success, why?
Where is the problem?

What’s wrong with these methods?

fName is the name of the file.
It’s necessary the full path data/filename.txt? It’s indifferent…

please help me with this stupid issue,
thanks.

  • 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-10T07:09:33+00:00Added an answer on June 10, 2026 at 7:09 am

    Your 2nd & 3rd approaches are wrong. When you include a text file locally in your app, you can’t refer it via the IS. Instead, use this function, it will return the file content if found else it will return "null". It works for me, hope it works for you.

    Note, if the file is set as content, the filePath = "data/filename.txt" but if it is set as resource it should be referred like this filePath = "/ProjectName;component/data/filename.txt". That may be why your 1st approach might have failed.

        private string ReadFile(string filePath)
        {
            //this verse is loaded for the first time so fill it from the text file
            var ResrouceStream = Application.GetResourceStream(new Uri(filePath, UriKind.Relative));
            if (ResrouceStream != null)
            {
                Stream myFileStream = ResrouceStream.Stream;
                if (myFileStream.CanRead)
                {
                    StreamReader myStreamReader = new StreamReader(myFileStream);
    
                    //read the content here
                    return myStreamReader.ReadToEnd();
                }
            }
            return "NULL";
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one folder called 'Data' that contains all files with current date in
say that i have a project which lies in a folder called 'bin', and
Currently in my project directory I have a folder called Data and in it
I am doing some rearrangements with my files, and I have a folder called
I have a folder, called files. It's already in the repository. Now, new files
I have a folder called data. It's in a subdirectory of my system, lets
I have a desktop software with a folder called Data. In this folder, I
I have got a plist in my Resources folder called levelconfig.plist and I want
I have an ASP.NET website project that until recent had all code in App_Code
I have a folder called Etc which has an image I want to use

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.