Click here to Skip to main content
16,008,075 members
Home / Discussions / C#
   

C#

 
AnswerRe: Problem with DataGrid in MultiThread enviroment Pin
Josh Smith5-Jun-06 8:57
Josh Smith5-Jun-06 8:57 
GeneralRe: Problem with DataGrid in MultiThread enviroment Pin
fan wei fang5-Jun-06 9:34
fan wei fang5-Jun-06 9:34 
GeneralRe: Problem with DataGrid in MultiThread enviroment Pin
Josh Smith5-Jun-06 10:29
Josh Smith5-Jun-06 10:29 
GeneralRe: Problem with DataGrid in MultiThread enviroment Pin
fan wei fang5-Jun-06 18:03
fan wei fang5-Jun-06 18:03 
Questiondate conversion Pin
kjosh5-Jun-06 5:51
kjosh5-Jun-06 5:51 
AnswerRe: date conversion Pin
Josh Smith5-Jun-06 5:56
Josh Smith5-Jun-06 5:56 
AnswerRe: date conversion Pin
User 66585-Jun-06 6:07
User 66585-Jun-06 6:07 
QuestionVB6 --> C# Binary file reading Pin
aldogon5-Jun-06 5:45
aldogon5-Jun-06 5:45 
Hi, this is the code i've been trying to convert from VB6 to C#...Is there any way to avoid reading every field of the struct and reaing the whole thing?

VB6 code:
--------------------------------------------------------
Type Person
sName as String * 12
Age as Byte
Code as Long
End Type

private persons() as Person


Sub LoadData(path As String)
dim hf as long
hf = FreeFile

dim recs as long
dim offset as long

open path for binary access read lock write as #hf

get #hf, 1, recs
get #hf, , offset

if recs > 0
redim persons(1 to recs)

'' Very easy way to retrieve UDT array data
get #hf, offset + 1, persons()
end if
End Sub



C#:
-------------------------------------------------------
using System;
using System.IO;
using System.Runtime.InteropServices;

//[StructLayout(LayoutKind.Sequential)]
public struct Person
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 12)]
string Name;
byte Age;
int Code;
}

public class PersonReader
{
private Person[] persons;

private void LoadData(string path)
{
Stream fileContents = File.Open(path, FileMode.Open);
BinaryReader binReader = new BinaryReader(fileContents);

int recs = binReader.ReadInt32();
int offset = binReader.ReadInt32();

binReader.BaseStream.Position = offset;

//Something like this should go here:
persons = binReader(...//read till the eof and convert it to Person[] :P

// Instead of a code that reads each data of the struct

binReader.Close();
fileContents.Close();
}
}
QuestionDetecting Process Pin
Hengy5-Jun-06 5:04
Hengy5-Jun-06 5:04 
AnswerRe: Detecting Process Pin
Josh Smith5-Jun-06 5:59
Josh Smith5-Jun-06 5:59 
QuestionSorting dates Pin
Yustme5-Jun-06 4:42
Yustme5-Jun-06 4:42 
AnswerRe: Sorting dates Pin
Josh Smith5-Jun-06 6:01
Josh Smith5-Jun-06 6:01 
GeneralRe: Sorting dates Pin
Yustme5-Jun-06 6:09
Yustme5-Jun-06 6:09 
GeneralRe: Sorting dates Pin
Dan Neely5-Jun-06 7:06
Dan Neely5-Jun-06 7:06 
GeneralRe: Sorting dates Pin
Yustme5-Jun-06 8:30
Yustme5-Jun-06 8:30 
GeneralRe: Sorting dates Pin
Dan Neely5-Jun-06 10:29
Dan Neely5-Jun-06 10:29 
GeneralRe: Sorting dates Pin
Josh Smith5-Jun-06 10:48
Josh Smith5-Jun-06 10:48 
AnswerRe: Sorting dates Pin
Dustin Metzgar5-Jun-06 6:10
Dustin Metzgar5-Jun-06 6:10 
QuestionHelp needed with string operation Pin
hasanali005-Jun-06 4:13
hasanali005-Jun-06 4:13 
AnswerRe: Help needed with string operation [modified] Pin
Wjousts5-Jun-06 4:52
Wjousts5-Jun-06 4:52 
QuestionProblem with GZipStream [modified] Pin
Dominik Reichl5-Jun-06 3:48
Dominik Reichl5-Jun-06 3:48 
AnswerRe: Problem with GZipStream [modified] Pin
Dominik Reichl5-Jun-06 6:11
Dominik Reichl5-Jun-06 6:11 
QuestionTextBox language !! Pin
Tamimi - Code5-Jun-06 3:35
Tamimi - Code5-Jun-06 3:35 
AnswerRe: TextBox language !! Pin
Josh Smith5-Jun-06 3:45
Josh Smith5-Jun-06 3:45 
QuestionVOIP integration Pin
ante.mihalj5-Jun-06 2:40
ante.mihalj5-Jun-06 2:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.