int counter = 0;
string line;
System.IO.StreamReader file =new System.IO.StreamReader("1.txt");
while((line = file.ReadLine()) != null)
{
listBox1.Items.Add(line);
int a=line.LastIndexOf(" ");
listBox1.Items.Add(a.ToString()+" "+line.Length);
listBox1.Items.Add(line.Substring(a,line.Length));
counter++;
}
未处理的“System.ArgumentOutOfRangeException”类型的异常出现在 mscorlib.dll 中。其他信息: 索引和长度必须引用该字符串内的位置。
listBox1.Items.Add(line.Substring(a,line.Length));这句怎么会错?
string line;
System.IO.StreamReader file =new System.IO.StreamReader("1.txt");
while((line = file.ReadLine()) != null)
{
listBox1.Items.Add(line);
int a=line.LastIndexOf(" ");
listBox1.Items.Add(a.ToString()+" "+line.Length);
listBox1.Items.Add(line.Substring(a,line.Length));
counter++;
}
未处理的“System.ArgumentOutOfRangeException”类型的异常出现在 mscorlib.dll 中。其他信息: 索引和长度必须引用该字符串内的位置。
listBox1.Items.Add(line.Substring(a,line.Length));这句怎么会错?
2006-10-21 16:44:25 0:12
2006-10-21 16:45:27 0:45
由
StreamWriter sw=new StreamWriter("1.txt",true);
sw.WriteLine(DateTime.Now.ToString()+" "+textBox1.Text);
写入