就是兴趣想学习下.NET
2个问题
1、
text.txt:http://bbs.meizu.com/thread-2112914-1-1.html
http://bbs.meizu.com/thread-2112914-1-1.html
http://bbs.meizu.com/thread-2112914-1-1.html
http://bbs.meizu.com/thread-2112914-1-1.html
http://bbs.meizu.com/thread-2112914-1-1.html
http://bbs.meizu.com/thread-2187060-1-1.html
http://bbs.meizu.com/thread-2187188-1-1.html
http://bbs.meizu.com/thread-2186292-1-1.html
http://bbs.meizu.com/thread-2185762-1-1.html
http://bbs.meizu.com/thread-2181568-1-1.html
http://bbs.meizu.com/thread-2181027-1-1.html
http://bbs.meizu.com/thread-2177253-1-1.html
http://bbs.meizu.com/thread-2173972-1-1.html
http://bbs.meizu.com/thread-2169638-1-1.html
http://bbs.meizu.com/thread-2165544-1-1.html
http://bbs.meizu.com/thread-2164649-1-1.html
http://bbs.meizu.com/thread-2163585-1-1.html
http://bbs.meizu.com/thread-2161817-1-1.html
代码如下: StreamReader data = new StreamReader("text.txt");
int i = 0;
DataGridViewRowCollection aa = dataGridView1.Rows;
string[] row ={"",""};
while(data.Read ()>0)
{
row[0] = i.ToString();
row[1] = data.ReadLine().ToString();
aa.Add(row);
i++;
}
读取后的"http"全部变成"ttp"
试用其他字符(包括中文字符)也是一样,总是每行的第一个字符被莫名其妙的丢失
请问是怎么回事?2、
另外请问如下这个,在C#中是什么控件实现的?
2个问题
1、
text.txt:http://bbs.meizu.com/thread-2112914-1-1.html
http://bbs.meizu.com/thread-2112914-1-1.html
http://bbs.meizu.com/thread-2112914-1-1.html
http://bbs.meizu.com/thread-2112914-1-1.html
http://bbs.meizu.com/thread-2112914-1-1.html
http://bbs.meizu.com/thread-2187060-1-1.html
http://bbs.meizu.com/thread-2187188-1-1.html
http://bbs.meizu.com/thread-2186292-1-1.html
http://bbs.meizu.com/thread-2185762-1-1.html
http://bbs.meizu.com/thread-2181568-1-1.html
http://bbs.meizu.com/thread-2181027-1-1.html
http://bbs.meizu.com/thread-2177253-1-1.html
http://bbs.meizu.com/thread-2173972-1-1.html
http://bbs.meizu.com/thread-2169638-1-1.html
http://bbs.meizu.com/thread-2165544-1-1.html
http://bbs.meizu.com/thread-2164649-1-1.html
http://bbs.meizu.com/thread-2163585-1-1.html
http://bbs.meizu.com/thread-2161817-1-1.html
代码如下: StreamReader data = new StreamReader("text.txt");
int i = 0;
DataGridViewRowCollection aa = dataGridView1.Rows;
string[] row ={"",""};
while(data.Read ()>0)
{
row[0] = i.ToString();
row[1] = data.ReadLine().ToString();
aa.Add(row);
i++;
}
读取后的"http"全部变成"ttp"
试用其他字符(包括中文字符)也是一样,总是每行的第一个字符被莫名其妙的丢失
请问是怎么回事?2、
另外请问如下这个,在C#中是什么控件实现的?
2.ListView
data.Read()后指针知道h后,
剩下ttp://bbs.meizu.com/thread-2112914-1-1.html
data.ReadLine() 从ttp读取到换行符
你文件如果能上传到某个地方。或许看一下就明白了。你可以传到csdn下载,或其他地方,这里贴连接。
while((line=data.ReadLine) != null)
{
...
}
data.ReadLine()读剩下的字符。
的确
一般这么写
string line = data.ReadLine();
while(line != null)
{
//处理行
line = data.ReadLine();
}
int i = 0;
DataGridViewRowCollection aa = dataGridView1.Rows;
string line = data.ReadLine();
while(line != null)
{
line = data.ReadLine();
row[0] = i.ToString();
row[1] = data.ReadLine().ToString();
aa.Add(row);
i++;
}2. 应该是ListView