0
的我在一些C++代碼轉換爲C#中,我試圖找出我怎麼能寫出來,在我的C#應用程序下面的C++代碼和過程有它做同樣的事情:C#相當於FREAD
fread(&Start, 1, 4, ReadMunge); //Read File position
我已經嘗試了多種方法,如使用的FileStream:
using (FileStream fs = File.OpenRead("File-0027.AFS"))
{
//Read amount of files from offset 4
fs.Seek(4, SeekOrigin.Begin);
FileAmount = fs.ReadByte();
string strNumber = Convert.ToString(FileAmount);
fileamountStatus.Text = strNumber;
//Seek to beginning of LBA table
fs.Seek(8, SeekOrigin.Begin);
CurrentOffset = fs.Position;
int numBytesRead = 0;
while (Loop < FileAmount) //We want this to loop till it reachs our FileAmount number
{
Loop = Loop + 1;
//fread(&Start, 1, 4, ReadMunge); //Read File position
//Start = fs.ReadByte();
//Size = fs.ReadByte();
CurrentOffset = fs.Position;
int CurrentOffsetINT = unchecked((int)CurrentOffset);
//Start = fs.Read(bytes,0, 4);
Start = fs.Read(bytes, CurrentOffsetINT, 4);
Size = fs.Read(bytes, CurrentOffsetINT, 4);
Start = fs.ReadByte();
}
}
我依然會碰到的問題是,Start/Size
不成立的4個字節的數據,我需要。