473,387 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to read a file with structure in csharp

Hi, everyone.

I have a file with structure as below.
Expand|Select|Wrap|Line Numbers
  1. public struct Security
  2.  
  3. {
  4.     public int StockNo (2 byte);
  5.     public String StockSymbol(8 byte);
  6.     public String StockType(1 byte);
  7.     public double Ceiling(4 byte);
  8.     public double Floor(4 bype);
  9.     public double BigLotValue(8 bype);
  10.     public string SecurityName(25 bype);
  11.     public string SectorNo(1 bype);
  12.     public string Designated(1 bype);
  13.     public string Suspension(1 bype);
  14.     public string Delist(1 bype);
  15.     public string HaltResumeFlag(1 bype);
  16.     public string Split(1 bype);
  17.     public string Benefit(1 bype);
  18.     public string Meeting(1 bype);
  19.     public string Notice(1 bype);
  20.     public string ClientIDRequest(1 bype);
  21.     public Int32 CouponRate(2 bype);
  22.     public string IssueDate(6 bype);
  23.     public string MatureDate(6 bype);
  24.     public double AvrPrice(4 bype);
  25.     public Int32 ParValue(2 bype);
  26.     public string SDCFlag(1 bype);
  27.     public double PriorClosePrice(4 bype);
  28.     public string PriorCloseDate(6 bype);
  29.     public double ProjectOpen(4 bype);
  30.     public double OpenPrice(4 bype);
  31.     public double Last(4 bype);
  32.     public double LastVol(4 bype);
  33.     public double LastVal(8 bype);
  34.     public double Highest(4 bype);
  35.     public double Lowest(4 bype);
  36.     public double Totalshare(8 bype);
  37.     public double TotalValue(2 bype);
  38.     public double AccumulateDeal(2 bype);
  39.     public Int32 BigDeal(4 bype);
  40.     public double BigVol(8 bype);
  41.     public double BigVal(2 bype);
  42.     public Int32 OddDeal(4 bype);
  43.     public double OddVol(8 bype);
  44.     public double OddVal(4 bype);
  45.     public double Best1Bid(4 bype);
  46.     public double Best1BidVolume(4 bype);
  47.     public double Best2Bid(4 bype);
  48.     public double Best2BidVolume(4 bype);
  49.     public double Best3Bid(4 bype);
  50.     public double Best3BidVolume(4 bype);
  51.     public double Best1Offer(4 bype);
  52.     public double Best1OfferVolume(4 bype);
  53.     public double Best2Offer(4 bype);
  54.     public double Best2OfferVolume(4 bype);
  55.     public double Best3Offer(4 bype);
  56.     public double Best3OfferVolume(4 bype);
  57.     public Int32 BoardLost(2 bype);
  58. }
Here is the orginal file http://www.mediafire.com/?fqtjzqvroji
The file is created by other person with other language program i do not know. I am also not sure it be done in binary write. How can i read all data and Binding to DataGrid in csharp.

I need your help.

Sorry for my bad english.

Thank in advanced.
Mar 8 '10 #1
1 1616
tlhintoq
3,525 Expert 2GB
TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.
Mar 8 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Michael Van Altena via .NET 247 | last post by:
I'm trying to figure out how to read a formatted binary file intoa structure definition in C#. I've tried using the"StructLayout" attribute with both LayoutKind.Explicit andLayoutKind.Sequential...
3
by: hunterb | last post by:
I have a file which has no BOM and contains mostly single byte chars. There are numerous double byte chars (Japanese) which appear throughout. I need to take the resulting Unicode and store it in a...
3
by: Bill Cohagan | last post by:
I'm writing a console app in c# and am encountering a strange problem. I'm trying to use redirection of the standard input stream to read input from a (xml) file. The following code snippet is from...
1
by: Hugh Creswell | last post by:
Hi there, I wonder if anyone can give me some help here? I am a newbie at csharp, and am translating a C++ app that I wrote into csharp. What I have is a and XmlDocument in memory, referenced by a...
9
by: james | last post by:
I have a FileStream retrieved from FileOpenDialog. I have a Byte which I intend to store for later use. What is the most efficient way of getting the File into my Byte and tehn back out to a new...
3
by: Dave Coate | last post by:
Hello again, I am going to re-post a question. I got some excellent suggestions from Rob and Mattias on this but their ideas did not solve the problem. Here is the original post: ...
8
by: a | last post by:
I have a struct to write to a file struct _structA{ long x; int y; float z; } struct _structA A; //file open write(fd,A,sizeof(_structA)); //file close
7
by: =?Utf-8?B?WWF0aW4gUGF0ZWw=?= | last post by:
Hi, I have a structure written in C++ / VC.NET and would like to convert that into CSharp. I am not getting any success. Can any of you please help me out. Following is the structure in C++:...
3
by: Ashutosh | last post by:
Hello, I am a newbie in CSharp. In C++ if we want to read from socket into the struct object we directly type cast it as recv(socketid,(char*),&struct_object,sizeof(struct object)) But C...
2
by: lttan123 | last post by:
I have two xml files with the same structure file1 <Topic> <Child> <wpf> <Child> <learn> <Child> </Child> <Link>
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.