50分求解,该怎么解决

50分求解
private void Form1_Load(object sender, EventArgs e)
  {
  FileStream FS = new FileStream("c:/trybook/trybook.txt",FileMode.Open);//根据路径创建文件流
  StreamReader reader = new StreamReader(FS);//创建读取器 
  string content = reader.ReadToEnd();//读取全部文件内容
  string[] strcontent = Regex.Split(content, "\r\n", RegexOptions.IgnoreCase);//用split方法将字符串拆成数组
  int j = strcontent.Length;
  for (int i=0;i<j;i++) 
  {
  Label trybookcontent = new Label();//创建新标签
  trybookcontent.Name = "lab" + i;
  trybookcontent.Text = i.ToString();
  this.Controls.Add(trybookcontent);
  } 
   
  }
运行结果为什么是0。那出错了断点J=4

------解决方案--------------------
protected void Page_Load(object sender, EventArgs e)
{
FileStream FS = new FileStream("c:/jiapengpeng.txt", FileMode.Open);//根据路径创建文件流
StreamReader reader = new StreamReader(FS);//创建读取器
string content = reader.ReadToEnd();//读取全部文件内容
string[] strcontent = Regex.Split(content, "\r\n", RegexOptions.IgnoreCase);//用split方法将字符串拆成数组
int j = strcontent.Length;
for (int i = 0; i < j; i++)
{
Label trybookcontent = new Label();//创建新标签
trybookcontent.ID= "lab" + i;
trybookcontent.Text = i.ToString();
this.Controls.Add(trybookcontent);
}
reader.Close();
}
不知道楼主“trybook.txt”文件里的内容是什么,刚开始时我在“jiapengpeng.txt”里连续输入了从0到9这十个数字(在同一行),结果显示的就是您刚才说的0,在“jiapengpeng.txt”里分行执行出了正确的结果。看楼主的代码可能是在asp.net下写的代码吧,trybookcontent.Name这一属性在代码里通不过,我这是用的是trybookcontent的ID属性。
------解决方案--------------------
FileStream FS = new FileStream("c:/trybook/trybook.txt",FileMode.Open);//根据路径创建文件流
改为
 FileStream FS = new FileStream("c:/trybook/trybook.txt",FileMode.Open ,FileAccess.Read ,FileShare.None ,1024);//根据路径创建文件流

------解决方案--------------------
FileStream FS = new FileStream("c:/trybook/trybook.txt",FileMode.Open);//根据路径创建文件流
改为
 FileStream FS = new FileStream("c:/trybook/trybook.txt",FileMode.Open ,FileAccess.Read ,FileShare.None ,1024);//根据路径创建文件流


楼上的你写上面这些有啥意思
------解决方案--------------------
不见得只有一个控件哦,Label的坐标没设置,可能是重叠了。单步跟踪一下,循环确实能进去J次。说明控件已经加进去了。只不过没看见而已。