当前位置: 首页>>代码示例>>C#>>正文


C# CsvParser.ReadFromFile方法代码示例

本文整理汇总了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");
                }

            }
        }
开发者ID:blel,项目名称:CargoConversionWizard,代码行数:32,代码来源:CargoConversionTool.cs

示例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");
         }
     }
 }
开发者ID:blel,项目名称:CargoConversionWizard,代码行数:33,代码来源:CargoConversionTool.cs


注:本文中的CsvParser.ReadFromFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。