有没有一种方法来读取两个多行文本框中的每一行?在
有没有一种方法可以读取textBox1的每一行,更改字符串并将其放入textBox2,然后将命令传递给expand.exe?
textBox1
中,我有一个包含使用以下代码压缩文件列表的多行字符串:DirectoryInfo getExpandDLL = new DirectoryInfo(showExpandPath);
FileInfo[] expandDLL = getExpandDLL.GetFiles("*.dl_");
foreach (FileInfo listExpandDLL in expandDLL)
{
textBox1.AppendText(listExpandDLL + Environment.NewLine);
}
目前我的代码的一部分如下:
textBox2.Text = textBox1.Text.Replace("dl_", "dll");
string cmdLine = textDir.Text + "\\" + textBox1.Text + " " + textDir.Text + "\\" + textBox2.Text;
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
startInfo.FileName = "expand.exe";
startInfo.UseShellExecute = true;
startInfo.Arguments = cmdLine.Replace(Environment.NewLine, string.Empty);
process.StartInfo = startInfo;
process.Start();
process.WaitForExit();
上面的代码获取textBox1中压缩文件的名称,将其重命名为textBox2,然后运行expand.exe以扩展压缩文件。该代码基本上给出了一个示例,即向expand.exe发出以下命令:
c:\users\nigel\desktop\file.dl_ c:\users\nigel\desktop\file.dll
如果文件夹中只包含 textBox1 中的一行文本,则它可以很好地工作。对于多行文本,命令基本上是:
c:\users\nigel\desktop\loadsoffiles.dl_ etc and doesnt work!
有没有一种方法可以读取textBox1的每一行,更改字符串并将其放入textBox2,然后将命令传递给expand.exe?
string cmdLine = textDir.Text + "\\" + lineOFtextBox1 + " " + textDir.Text + "\\" + lineOftextBox2;
编辑:为了明确起见:TextBox1 包含以下内容:
- somefile.dl_
- someMore.dl_
- evenmore.dl_
这是多行文本。我的代码将该多行文本放入 textBox2,因此其包含以下内容:
- somefile.dll
- someMore.dll
- evenmore.dll
有没有一种方法可以读取 textBox1 和 textBox2 的每一行 / 每一行的内容,并对其进行“处理”?
谢谢!
Regex.Split
来完成。 - JaxidianDirectoryInfo.GetFiles
的所有输出放入文本框中,然后再尝试解析其中的字符串? - I4V