如何创建一个应用程序来读取没有任何标题的csv文件?

时间:2017-09-11 17:12:12

标签: c# .net winforms visual-studio csv

想要创建一个不带任何列标题和引号的读取和编辑csv文件的应用程序。 我已编码最大部分,但它 测试没有标题的文件时出错。

    private void LoadFile(string filePath)
    {
        Arguments arg = new Arguments();
        arg.Task = Work.task_open;
        arg.Add(BackgroundWorkArgumentKeys.openfile, filePath);
        arg.Add(BackgroundWorkArgumentKeys.setFirstRowAsHeader, true);

        this.grid.Enabled = false;

        this._BackgroundWorker.RunWorkerAsync(arg);
    }

    private void LoadFile()
    {
        this.LoadFile(this.grid.CurrentFilePath);
    }

    private void SaveFile(string filePath)
    {
        this.UpdateDataSource();

        Arguments arg = new Arguments();
        arg.Task = Work.TASK_SAVE;
        arg.Add(BackgroundWorkArgumentKeys.savefilepath, filePath);
        arg.Add(BackgroundWorkArgumentKeys.savedatasource, (DataTable)this.grid.DataSource);
        arg.Add(BackgroundWorkArgumentKeys.setFirstRowAsHeader, true);

        this.grid.Enabled = false;

        this._BackgroundWorker.RunWorkerAsync(arg);
    }

0 个答案:

没有答案