110,533
社区成员
发帖
与我相关
我的任务
分享
private void button1_Click(object sender, EventArgs e)
{
Process p = Process.Start(@"notepad.exe",@" D:\LUKE\LukeWikipedia\模拟登录.txt");
p.WaitForInputIdle(1000); //等一秒,等文本打开,焦点去到notepad
SendKeys.SendWait("{DOWN 6}"); //向下移动6行
SendKeys.SendWait("{HOME}"); //行首
SendKeys.SendWait("+{END}"); //选中当前行
}
using System.IO;
StreamReader sr = new StreamReader(@"E:\WebPage\2011-04-12\248808221\250167153.txt");//你的txt文件路径
int i=0;
string rowstring = "";
while (sr.Peek() > 0)
{
rowstring = sr.ReadLine();// 获取当前行字符串
i++;//用于标记现在读到第几行
if(i==你自己想要的行号)
{
break;
}
}
sr.Close();