• 大小: 5.95MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-08-16
  • 语言: 其他
  • 标签: CSV  

资源简介

在自动化机器的程序中,保存生产数据广泛应用CSV文件格式。 CSVHelper类用于创建或者解析标准逗号分隔符的CSV文件

资源截图

代码片段和文件信息

using sharClass;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace csvhelperTest
{
    public partial class Form1 : Form
    {
        private string path = AppDomain.CurrentDomain.baseDirectory + “csvdata.csv“;
        private List list1 = new List();
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender EventArgs e)
        {

        }

        private void button1_Click(object sender EventArgs e)
        {
            var txt = tblistField.Text;
            if(txt.Length>0)
            {
                list1.Add(txt);
            }
            listBox1.DataSource = null;
            listBox1.DataSource = list1;
        }

        private void btnCreateCSV_Click(object sender EventArgs e)
        {
            try
            {
                var s1 = CSVHelper.createCSVRow(list1);
                File.WriteAllText(path s1);
                System.Diagnostics.Process.Start(path);
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void btnReadCSV_Click(object sender EventArgs e)
        {
            try
            {
                var list2 = CSVHelper.explainCSVRow(File.ReadAllText(path));
                listBox2.DataSource = null;
                listBox2.DataSource = list2;
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    ..A..H.     51200  2019-01-30 14:32  csvHelper类测试\csvhelperTest\.vs\csvhelperTest\v15\.suo

     文件          0  2019-01-30 08:59  csvHelper类测试\csvhelperTest\.vs\csvhelperTest\v15\Server\sqlite3\db.lock

     文件       4096  2019-01-30 08:59  csvHelper类测试\csvhelperTest\.vs\csvhelperTest\v15\Server\sqlite3\storage.ide

     文件      32768  2019-01-30 08:59  csvHelper类测试\csvhelperTest\.vs\csvhelperTest\v15\Server\sqlite3\storage.ide-shm

     文件    3592672  2019-01-30 13:35  csvHelper类测试\csvhelperTest\.vs\csvhelperTest\v15\Server\sqlite3\storage.ide-wal

     文件        541  2019-01-30 10:05  csvHelper类测试\csvhelperTest\csvhelperTest\App.config

     文件     355840  2016-11-24 01:14  csvHelper类测试\csvhelperTest\csvhelperTest\bin\Debug\Allegro.base.Motion.GTS.dll

     文件     228864  2016-11-24 01:14  csvHelper类测试\csvhelperTest\csvhelperTest\bin\Debug\Allegro.dll

     文件         21  2019-01-30 13:19  csvHelper类测试\csvhelperTest\csvhelperTest\bin\Debug\csvdata.csv

     文件      10240  2019-01-30 13:18  csvHelper类测试\csvhelperTest\csvhelperTest\bin\Debug\csvhelperTest.exe

     文件        541  2019-01-30 10:05  csvHelper类测试\csvhelperTest\csvhelperTest\bin\Debug\csvhelperTest.exe.config

     文件      22016  2019-01-30 13:18  csvHelper类测试\csvhelperTest\csvhelperTest\bin\Debug\csvhelperTest.pdb

     文件     850168  2010-09-23 09:42  csvHelper类测试\csvhelperTest\csvhelperTest\bin\Debug\halcondotnet.dll

     文件     259464  2010-03-18 12:15  csvHelper类测试\csvhelperTest\csvhelperTest\bin\Debug\Microsoft.VisualBasic.PowerPacks.Vs.dll

     文件      86016  2009-05-02 12:27  csvHelper类测试\csvhelperTest\csvhelperTest\bin\Debug\Modbus.dll

     文件     266240  2007-08-22 03:30  csvHelper类测试\csvhelperTest\csvhelperTest\bin\Debug\MySql.Data.dll

     文件    1720320  2018-12-29 06:03  csvHelper类测试\csvhelperTest\csvhelperTest\bin\Debug\netMarketing.dll

     文件    1230680  2018-12-29 06:03  csvHelper类测试\csvhelperTest\csvhelperTest\bin\Debug\netMarketing.xml

     文件     664576  2018-02-18 01:41  csvHelper类测试\csvhelperTest\csvhelperTest\bin\Debug\Newtonsoft.Json.dll

     文件     123392  2018-12-29 06:03  csvHelper类测试\csvhelperTest\csvhelperTest\bin\Debug\sharClass.dll

     文件     625664  2018-12-29 06:03  csvHelper类测试\csvhelperTest\csvhelperTest\bin\Debug\UserUI.dll

     文件     248832  2017-11-29 05:36  csvHelper类测试\csvhelperTest\csvhelperTest\bin\Debug\Utility.dll

     文件      78848  2017-10-28 01:39  csvHelper类测试\csvhelperTest\csvhelperTest\bin\Debug\Utility.Ports.dll

     文件     456704  2018-08-29 06:08  csvHelper类测试\csvhelperTest\csvhelperTest\bin\Debug\WeifenLuo.WinFormsUI.Docking.dll

     文件       6547  2019-01-30 10:05  csvHelper类测试\csvhelperTest\csvhelperTest\csvhelperTest.csproj

     文件       1791  2019-01-30 11:47  csvHelper类测试\csvhelperTest\csvhelperTest\Form1.cs

     文件       5115  2019-01-30 11:44  csvHelper类测试\csvhelperTest\csvhelperTest\Form1.Designer.cs

     文件       5817  2019-01-30 11:44  csvHelper类测试\csvhelperTest\csvhelperTest\Form1.resx

     文件          0  2019-01-30 13:18  csvHelper类测试\csvhelperTest\csvhelperTest\obj\Debug\csvhelperTest.csproj.CopyComplete

     文件         42  2019-01-30 10:05  csvHelper类测试\csvhelperTest\csvhelperTest\obj\Debug\csvhelperTest.csproj.CoreCompileInputs.cache

............此处省略57个文件信息

评论

共有 条评论