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

The Archive Base Latest Questions

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

Possible Duplicate: How to read a text file line by line Windows RT? I

  • 0

Possible Duplicate:
How to read a text file line by line Windows RT?

I am trying to read from file line by line in C#.

This is my code

   String filename = "apoel.txt";

   System.IO.StreamReader file = new System.IO.StreamReader(filename);

I followed instructions from an MSDN page and followed them exactly. The problem is I keep getting the errors

The best overloaded method match for System.IO.StreamReader.StreamReader (System.IO.Stream)’ has some
invalid arguments
Argument 1: cannot convert from ‘string’ to ‘System.IO.Stream’

I added using System.IO; on the top of my code

What am I doing wrong? If it is of any help this is a Windows Metro app

Also can someone explain to me why the article from MSDN that I post is wrong and not working? Do not give me an alternative please. Please tell me why my code is not working while it is explained like that in MSDN

  • 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-16T18:31:11+00:00Added an answer on June 16, 2026 at 6:31 pm

    Here is the code i use for Reading/Writing a file in Windows 8. It works and i hope it helps you too.

    private StorageFolder localFolder;
    // Read from a file line by line
    public async Task ReadFile()
    {
        try
        {
            // get the file
            StorageFile myStorageFile = await localFolder.GetFileAsync("MyDocument.txt");
            var readThis = await FileIO.ReadLinesAsync(myStorageFile);
            foreach (var line in readThis)
            {
                String myStringLine = line;
            }
            Debug.WriteLine("File read successfully.");
        }
        catch(FileNotFoundException ex)
        {   
            Debug.WriteLine(ex);           
        }
    }
    // Write to a file line by line
    public async void SaveFile()
    {
        try
        {
            // set storage file
            StorageFile myStorageFile = await localFolder.CreateFileAsync("MyDocument.txt", CreationCollisionOption.ReplaceExisting);
            List<String> myDataLineList = new List<string>();
            await FileIO.WriteLinesAsync(myStorageFile, myDataLineList);
            Debug.WriteLine("File saved successfully.");
        }
        catch(FileNotFoundException ex)
        {  
            Debug.WriteLine(ex);            
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Read a specific line from a text file Is there any way
Possible Duplicate: read/write to Windows Registry using Java I'm trying to run this cmd
Possible Duplicate: Reading from text file until EOF repeats last line c++ EOF running
Possible Duplicate: Whole text file to a String in Java How can I read
Possible Duplicate: How do I read this text file and Insert into MySQL? I
Possible Duplicate: Reading the last n lines from a huge text file I have
Possible Duplicate: How to create a Java String from the contents of a file
Possible Duplicate: How to read a text file reversely with iterator in C# I
Possible Duplicate: How do I tokenize a string in C++? I have this text
Possible Duplicate: How to read embedded resource text file I try to create a

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.