数据存储疑问...求大侠解答
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using
using System.Runtime.InteropServices;
using MySql.Data;
using MySql.Data.MySqlClient;
namespace Post
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
// public struct Information
// {
// public string Name;
// public int Number;
// public int SellPrice;
// public int UnitPrice;
// public int BarCode;
// }
private void button1_Click(object sender, EventArgs e)
{
string filepath =@"D:\My Documents\Visual Studio 2008\Projects\Post\Post\Data\2012720.013";
StreamWriter sw = new StreamWriter(filepath, true, System.Text.Encoding.GetEncoding("GB2312"));
string fs = "";
for (int i = 0; i < (dataGridView1.Rows.Count - 1); i++)
{
fs = "";
for (int j = 0; j < dataGridView1.Columns.Count; j++)
{
//currentcell :访问当前表格;
this.dataGridView1.CurrentCell = this.dataGridView1.Rows[i].Cells[j];
Clipboard.SetDataObject(dataGridView1.GetClipboardContent());
fs =fs+Clipboard.GetText().ToString()+" || ";
}
sw.WriteLine(fs);
}
sw.Flush();
sw.Close();
}
}
}
这是直接存到txt文档中的,我想知道怎么通过结构体数组来存储数据,然后再转存到TXT文本中,哪位高手帮忙修改下代码,让我参考下
[local]1[/local]
[ 本帖最后由 BlizzardKen 于 2012-7-21 11:39 编辑 ]