Click here to Skip to main content
15,896,063 members
Articles / Programming Languages / C# 4.0

read text file lines into array

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
14 Nov 2012CPOL 3.7K  
Hi,i have two textboxes.I have a text file that has list of file paths for different scripts used on our network.the file is setup like this:C:\Scripts\dnsflush.ps1C:\Scripts\DFQ.ps1D:\N\Exchange\Netservicestop.ps1D:\AD\scripts\ugroups.ps1i want to only read the lines...

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

Please Sign up or sign in to vote.
14 Nov 2012 Orcun Iyigun
One way of doing it is;string filename = "yourtextfilepath.txt";if (File.Exists(filename)){ string[] lines = File.ReadAllLines(filename); Console.WriteLine(lines["the line number that you want to print - 1"]);}If you dont want to read all the lines here is another...

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions