Click here to Skip to main content
16,017,249 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi, Guys.

How to read all data record in Struct file.
here is code i tried but error when i run.

C#
using System;
using System.Data;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization;
public class CreateFile
{
    static void Main()
    {
        BinaryFormatter reader = new BinaryFormatter();
        FileStream input = new FileStream(@"C:\Users\huynhdt\Desktop\Ftp\SECURITY.DAT", FileMode.Open, FileAccess.Read);
        Security record1 = (Security)reader.Serialize(input);
        Console.WriteLine(record1.StockNo);
        Console.ReadLine();
    }
}
[Serializable]
public class Security
{
    public int StockNo;
    public String StockSymbol;
    public String StockType;
    public double Ceiling;
    public double Floor;
    public double BigLotValue;
    public string SecurityName;
    public string SectorNo;
    public string Designated;
    public string Suspension;
    public string Delist;
    public string HaltResumeFlag;
    public string Split;
    public string Benefit;
    public string Meeting;
    public string Notice;
    public string ClientIDRequest;
    public Int32 CouponRate;
    public string IssueDate;
    public string MatureDate;
    public double AvrPrice;
    public Int32 ParValue;
    public string SDCFlag;
    public double PriorClosePrice;
    public string PriorCloseDate;
    public double ProjectOpen;
    public double OpenPrice;
    public double Last;
    public double LastVol;
    public double LastVal;
    public double Highest;
    public double Lowest;
    public double Totalshare;
    public double TotalValue;
    public double AccumulateDeal;
    public Int32 BigDeal;
    public double BigVol;
    public double BigVal;
    public Int32 OddDeal;
    public double OddVol;
    public double OddVal;
    public double Best1Bid;
    public double Best1BidVolume;
    public double Best2Bid;
    public double Best2BidVolume;
    public double Best3Bid;
    public double Best3BidVolume;
    public double Best1Offer;
    public double Best1OfferVolume;
    public double Best2Offer;
    public double Best2OfferVolume;
    public double Best3Offer;
    public double Best3OfferVolume;
    public Int32 BoardLost;
}


And file Security.Dat http://www.mediafire.com/?fqtjzqvroji[^]

Help me soon. Thanks in advanced.
Posted
Updated 5-Mar-10 14:59pm
v7

1 solution

What *exactly* is your question?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900