static string goodBarcodeFile = @"F:\新建文件夹\珠海冠宇-P037 烧录\珠海冠宇-P037-Prog-V1-S1\TestPmg\TestPmg\bin\Debug\goodBarcodes.txt"; static string badBarcodeFile = @"F:\新建文件夹\珠海冠宇-P037 烧录\珠海冠宇-P037-Prog-V1-S1\TestPmg\TestPmg\bin\Debug\badBarcodes.txt"; List<string> goodBarcodeList = System.IO.File.ReadAllLines(goodBarcodeFile).ToList(); List<string> badBarcodeList = System.IO.File.ReadAllLines(badBarcodeFile).ToList();在上述代码基础上修改,良品不良品条码不是在本地文件夹获取,而是在另一个设置窗体(不是主窗体)UCTextboxEx组件,名字为txt_goodCode
时间: 2023-06-30 18:17:16 浏览: 46
将上述代码放在设置窗体中,并将goodBarcodeFile和badBarcodeFile修改为以下代码:
```
string goodBarcodeText = txt_goodCode.Text;
string badBarcodeText = txt_badCode.Text;
List<string> goodBarcodeList = goodBarcodeText.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList();
List<string> badBarcodeList = badBarcodeText.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList();
```
这样就可以从设置窗体的txt_goodCode和txt_badCode控件中获取良品和不良品条码列表了。注意要使用Split方法将文本框中的多行文本按行分割成字符串列表。