Skip to main content
gamedev.net
🔒 Locked

[SOLVED]VB6 - C#

Started by brwarner 5 replies 650+ views
Original Post
brwarner
brwarner
I want to convert this:

Open fzpath For Binary As #free
Get #free, 1, floop
ReDim files(floop)
For fcount = 1 To floop
'structlen = 50 = sizeof(files)
Get #free, (fcount * structlen) + 5, files(fcount).offset
Get #free, (fcount * structlen) + 5 + 4, files(fcount).length
Get #free, (fcount * structlen) + 5 + 8, files(fcount).name 'string * 10
Get #free, (fcount * structlen) + 5 + 18, files(fcount).type
Get #free, (fcount * structlen) + 5 + 22, files(fcount).type2
Get #free, (fcount * structlen) + 5 + 26, files(fcount).width
Get #free, (fcount * structlen) + 5 + 28, files(fcount).height
Get #free, (fcount * structlen) + 5 + 30, files(fcount).unk1
Get #free, (fcount * structlen) + 5 + 31, files(fcount).unk2
Get #free, (fcount * structlen) + 5 + 32, files(fcount).unk3
Get #free, (fcount * structlen) + 5 + 33, files(fcount).unk4
Get #free, (fcount * structlen) + 5 + 34, files(fcount).unk5
Get #free, (fcount * structlen) + 5 + 36, files(fcount).unk6
Get #free, (fcount * structlen) + 5 + 38, files(fcount).unk7
Get #free, (fcount * structlen) + 5 + 42, files(fcount).fnum
Get #free, (fcount * structlen) + 5 + 46, files(fcount).rlength
'Form1.List1.AddItem files(fcount).name
'50
Next fcount


To C#. I tried this ->

BinaryReader s = new BinaryReader(File.Open(input,FileMode.Open,FileAccess.Read));
        long floop = s.ReadInt64();
        string[] names = new string[floop];
        long[] sizes = new long[floop];
        for (int i = 0; i < floop; i++)
        {
            s.BaseStream.Seek(50 * i + 8 + 5, SeekOrigin.Begin);
            names = new string(s.ReadChars(10));
            s.BaseStream.Seek(50 * i + 42 + 5,SeekOrigin.Begin);
            sizes = s.ReadInt64();
        }
        s.Close();
        return null;


to get the name and id vaulues but get strange results... [Edited by - brwarner on July 12, 2006 9:03:31 AM]
Dave Hunt
Dave Hunt
You are using long and ReadInt64(), but from the original code it looks like you should be using int and ReadInt32(). The numeric fields in your files structure are 4 bytes apart in the file, not 8, so 32 bits, not 64.
brwarner
brwarner
^THat was me.. srry
brwarner
brwarner
I found the problem. For the string I changed the offset from 8 + 5 to 8 + 4 and it works now..
daerid
daerid
Please see this post.
daerid@gmail.com

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.