
Untitled
By: a guest on
Jun 21st, 2012 | syntax:
None | size: 1.33 KB | hits: 10 | expires: Never
Extracting specific data from a file
using (StreamReader sr = new StreamReader("TabDelimited.txt"))
{
string line;
// Read and display lines from the file until the end of
// the file is reached.
while ((line = sr.ReadLine()) != null)
{
int idx = line.IndexOf(' ');
if (idx < 0)
continue;
// get the uid
string uid = line.Substring(0, idx - 1);
}
}
using (StreamReader sr = new StreamReader("TabDelimited.txt"))
{
string line;
// Read and display lines from the file until the end of
// the file is reached.
while ((line = sr.ReadLine()) != null)
{
int idx = line.IndexOf(' ');
if (idx < 0)
continue;
// get the uid
string uid = line.Substring(0, idx - 1);
}
}
using (StreamReader sr = new StreamReader("TabDelimited.txt"))
{
string line;
// Read and display lines from the file until the end of
// the file is reached.
while ((line = sr.ReadLine()) != null)
{
int idx = line.IndexOf(' ');
if (idx < 0)
continue;
// get the uid
string uid = line.Substring(0, idx - 1);
}
}
string [] strArray = File.ReadAllLines(path);
string [] line1 =strArray[0].Split(' ');