我使用这个janus代码,但我的导出文件是0字节

时间:2014-11-01 10:44:35

标签: janus

我使用此代码但我的导出文件是0字节

 saveFileDialog1.ShowDialog();
        if (saveFileDialog1.FileName != "")
        {
            System.IO.FileStream st = new System.IO.FileStream(saveFileDialog1.FileName, System.IO.FileMode.Create);
            this.gridEXExporter1.ExportMode = Janus.Windows.GridEX.ExportMode.AllRows;
            gridEXExporter1.GridEX = gridEX1;
            gridEXExporter1.Export(st);
            st.Close();
            System.Diagnostics.Process.Start(saveFileDialog1.FileName);
        }

1 个答案:

答案 0 :(得分:0)

试试这段代码,它适用于我:

    if (saveFileDialog.ShowDialog() == DialogResult.OK)
    {
        using (FileStream fs = new FileStream(saveFileDialog.FileName, FileMode.Create, FileAccess.Write, FileShare.ReadWrite))
        {
            gridEXExporter.Export(fs);
        }
    }