//[StructLayout(LayoutKind.Sequential)]
[Serializable]
public struct RECORD
{
public long date;
public long open;
public long hight;
public long low;
public long close;
public long travl;
public long traca;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public byte[] unuse;
}
RECORD reco;
private void button3_Click(object sender, EventArgs e)
{
string file = "0000001.day";
if (File.Exists(file))
{
FileStream fs = File.Open(file, FileMode.Open);
readdrec(fs);
fs.Close();
}
else
{
//printf(_T("Error..............."));
}
}
int readdrec(FileStream fs)
{
float fn;
unsafe
{
//int sizetoread = sizeof(RECORD);
//byte[] buffer = new byte[sizetoread];
//fs.Read(buffer, 0, sizetoread);
try
{
BinaryFormatter bf = new BinaryFormatter();
reco = (RECORD)bf.Deserialize(fs);
fn = ((float)reco.open)/1000;
MessageBox.Show(fs.ToString());
//......等等
}
catch (Exception) { } }
return 0;
}
[Serializable]
public struct RECORD
{
public long date;
public long open;
public long hight;
public long low;
public long close;
public long travl;
public long traca;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public byte[] unuse;
}
RECORD reco;
private void button3_Click(object sender, EventArgs e)
{
string file = "0000001.day";
if (File.Exists(file))
{
FileStream fs = File.Open(file, FileMode.Open);
readdrec(fs);
fs.Close();
}
else
{
//printf(_T("Error..............."));
}
}
int readdrec(FileStream fs)
{
float fn;
unsafe
{
//int sizetoread = sizeof(RECORD);
//byte[] buffer = new byte[sizetoread];
//fs.Read(buffer, 0, sizetoread);
try
{
BinaryFormatter bf = new BinaryFormatter();
reco = (RECORD)bf.Deserialize(fs);
fn = ((float)reco.open)/1000;
MessageBox.Show(fs.ToString());
//......等等
}
catch (Exception) { } }
return 0;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货