[英]I need help removing items from listbox and loading different set of items from a file
Ok, so I'm working on an automated browser using cefsharp on winforms C#. 好的,所以我正在使用在Winforms C#上使用cefsharp的自动浏览器。 I am currently loading 150 URLs into a listbox from a file on my pc and it is working just fine.
我目前正在从PC上的文件中将150个URL加载到列表框中,并且工作正常。 What I need is to load a different text file into the listbox after it's done, and then a different one and so on.
我需要的是在完成后将另一个文本文件加载到列表框中,然后再加载另一个,依此类推。
string[] lines = File.ReadAllLines(@"Links1.txt");
listbox1.Items.AddRange(lines);
I have that on a button and it and then I have the code to load the urls, if you need to see that let me know. 我将其放在按钮上,然后,如果需要查看该代码,便可以加载网址。 So what I need to do after that is load Links2.txt and then Links3.txt, and so on in total there's 264 text files.
因此,在此之后我需要做的是先加载Links2.txt,然后再加载Links3.txt,以此类推,总共有264个文本文件。
Please let me know if there's a better way of doing this and if so how? 请让我知道是否有更好的方法可以,如果可以的话如何? Thank you.
谢谢。
So what I need to do after that is load Links2.txt and then Links3.txt, and so on in total there's 264 text files.
因此,在此之后我需要做的是先加载Links2.txt,然后再加载Links3.txt,以此类推,总共有264个文本文件。
Use a for loop: 使用for循环:
for (int i = 0; i < 265;i++)
{
string[] lines = File.ReadAllLines(@"Links" + i.ToString() + ".txt");
listbox1.Items.AddRange(lines);
//Load the listbox items into cefsharp
...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.