读取文本文件,然后根据文本文件第一列中存在的唯一代码将其拆分为多个文件-基于第一列中的唯一代码标识符,每条记录的列结构都会有所不同。 带有逗号分隔符的文本文件 我想根据第一列中的唯一代码标识符将上述文本文件拆分为文本文件。 预期两个文件的数据如下 注意:由于每个代码标 ...
提示:本站收集StackOverFlow近2千万问答,支持中英文搜索,鼠标放在语句上弹窗显示对应的参考中文或英文, 本站还提供 中文繁体 英文版本 中英对照 版本,有任何建议请联系yoyou2525@163.com。
我想使用唯一的代码从C#语言的文本文件中读取特定行,该代码将显示行号,而我正努力在任何网站上获取该行,它们显示了很多但不完全是我想要的内容,这是我的代码:
namespace MyQuestion2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnDisplay_Click(object sender, EventArgs e)
{
//opens the file dialog
OpenFileDialog ofd = new OpenFileDialog();
//checks to see if the user does open a file dialog
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
//reads the file that the user opens
StreamReader sr = new StreamReader(File.OpenRead(ofd.FileName));
txtOutput.Text = sr.ReadToEnd();
sr.Dispose();
}
}
private void TxtProductCode_TextChanged(object sender, CancelEventArgs e)
{
TextBox tb = sender as TextBox;
if (tb != null)
{
int i;
if (int.TryParse(tb.Text, out i))
{
if (i >= 0 && i <= 5)
return;
}
}
MessageBox.Show("The number you have put is less than 0 or higher that 5! Please try again");
e.Cancel = true;
}
}
}
提前致谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.