本文整理汇总了C#中CsvParser.ReadFromFile方法的典型用法代码示例。如果您正苦于以下问题:C# CsvParser.ReadFromFile方法的具体用法?C# CsvParser.ReadFromFile怎么用?C# CsvParser.ReadFromFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CsvParser
的用法示例。
在下文中一共展示了CsvParser.ReadFromFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnTryLoad_Click
/// <summary>
/// Loads the file into the FlatCargoFile private field
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnTryLoad_Click(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(txtFileName.Text))
{
txtResults.Text = string.Empty;
CsvParser<FlatPrimeRecord> csvParser = new CsvParser<FlatPrimeRecord>();
csvParser.ValidationErrorOccurred += new CsvParser<FlatPrimeRecord>.ValidationErrorOccuredHandler(csvParser_ValidationErrorOccurred);
try
{
txtResults.Text += "Start reading file...\r\n";
_flatCargoFile = new FlatPrimeFile(csvParser.ReadFromFile(txtFileName.Text, ";", chkHasHeaders.Checked));
txtResults.Text += "\r\nEnd reading file.\r\n";
txtResults.Text += string.Format("Total {0} of {1} lines imported.", csvParser.ImportedLineCount, csvParser.TotalLineCount);
}
catch (IOException ex)
{
txtResults.AppendText(ex.Message + "\r\n");
}
catch (Exception ex)
{
txtResults.AppendText(ex.Message + "\r\n");
}
}
}
示例2: btnTryLoadRejectionFile_Click
/// <summary>
/// Loads teh rejection file
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnTryLoadRejectionFile_Click(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(txtRejectionFile.Text))
{
txtRejectionFileLoadResults.Text = "";
CsvParser<FlatRejectionRecord> csvParser = new CsvParser<FlatRejectionRecord>();
csvParser.ValidationErrorOccurred += new CsvParser<FlatRejectionRecord>.ValidationErrorOccuredHandler(csvParser_RejectionErrorOccurred);
try
{
txtRejectionFileLoadResults.Text += "Start reading file...\r\n";
_flatRejectionFile = new FlatRejectionFile(csvParser.ReadFromFile(txtRejectionFile.Text, ";", chkHasHeaders.Checked));
txtRejectionFileLoadResults.Text += "\r\nEnd reading file.";
txtRejectionFileLoadResults.Text += string.Format("Total {0} of {1} lines imported.", csvParser.ImportedLineCount, csvParser.TotalLineCount);
if (_flatRejectionFile.GetInvoiceCount() > 0 || _flatCargoFile.GetInvoiceCount() > 0)
this.btnNext.Enabled = true;
else
this.btnNext.Enabled = false;
}
catch (IOException ex)
{
txtRejectionFileLoadResults.AppendText(ex.Message + "\r\n");
}
catch (Exception ex)
{
txtRejectionFileLoadResults.AppendText(ex.Message + "\r\n");
}
}
}