I need to write the programming which to read the data file, start from the second line.
here, i provide u my code.
List<string> fi = new List<string>();
using (StreamReader sr = new StreamReader("c:\\PODB.txt"))
{
string line = null;
while ((line = sr.ReadLine()) != null)
{
fi.Add(line); //add to list
Console.WriteLine(line); //write to console
}
}
what i have to insert into my code..need help..ThanK you
read data from notepad
Started by royvb, Mar 28 2010 09:07 PM
1 reply to this topic
#1
Posted 28 March 2010 - 09:07 PM
|
|
|
#2
Posted 30 March 2010 - 02:35 PM
umm...... your trying to read the second line of a .txt file? If so this might help:
EDIT: You will need to make it a string array not decimal. ;)
openFileDialog1.FileName = "";
openFileDialog1.Title = "Open A Business Document.";
openFileDialog1.Filter = "Business|*.bus";
DialogResult result = openFileDialog1.ShowDialog(); // Show the dialog.
if (result == DialogResult.OK) // Test result.
{
int i = 0;
string file = openFileDialog1.FileName;
try
{
decimal[] Restore;
Restore = new decimal[22];
string line;
// Read the file and display it line by line.
using (StreamReader doc = new StreamReader(openFileDialog1.FileName))
{
while ((line = doc.ReadLine()) != null)
{
Restore[i] = Convert.ToDecimal(line);
i++;
}
#region Change Values
//Wokers cost
Workers.Value = Restore[0];
HourPayment.Value = Restore[1];
HourPerDay.Value = Restore[2];
DaysPerWeek.Value = Restore[3];
}
}
catch
{
MessageBox.Show("An error has occurred");
} That basically opens a .txt file into an array which you can take the value's from, for what you need.EDIT: You will need to make it a string array not decimal. ;)
A man can be defined by what he does when no one is looking.
Science is only an educated theory, which we cannot disprove.
Science is only an educated theory, which we cannot disprove.


Sign In
Create Account

Back to top









