READ SPECIFIC TEXTFILE IN STREAMREADER

Ashish Pandey

Total Post:128

Points:898
Posted by  Ashish Pandey
C# 
C#
 1240  View(s)
Ratings:
Rate this:

I want to read many delimited files from a folder. However, the calling in the code is per one textfile only.

System.IO.StreamReader file =new System.IO.StreamReader(@"C:\Orders\OrdersForImport.txt");

I want the "OrdersForImport.txt" to be change.

my textfiles are OrdersForImport, OrdersForImport1, OrdersForImport2, OrdersForImport3, etc.

it is constant that the ".txt" extention will not be change. only the filenames will be change

  1. ezra heywood

    Post:145

    Points:1019
    Re: Read Specific textfile in streamreader

    Hi Ashish,

    You'll have to run a loop and read all of them then ...

    You could do something like

    var name_array = "name1.name2.name3".Split(".");

    and then look and same the input like

    var sb = new StringBuilder();

    foreach (var entry in name_array)

    {

       var name = entry +".txt";

       // read your file here giving the `name` to the streamreader

    }

      Modified On Apr-04-2016 11:19:08 PM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!