public bool ImportRaw(string ImportFileName, bool isForceImport) { bool Result = true; this.ImportResult = ""; try { int Mark1 = (int)'{'; int Mark2 = (int)'}'; int Current = 0x00; int ReadPointer = 0; int WritePointer = 0; FileStream theFile = new FileStream(ImportFileName, FileMode.Open); byte[] ReadBuffer = new byte[theFile.Length]; //Generate Header Length int Balance = 0; bool FindFirstMark = false; while (FindFirstMark == false || Balance != 0) { Current = theFile.ReadByte(); ReadPointer++; ReadBuffer[WritePointer] = (byte)Current; WritePointer++; if (Current == Mark1) { FindFirstMark = true; Balance++; } else if (Current == Mark2) Balance--; } this.HeaderOri = Encoding.ASCII.GetString(Library.SubByteArray(ReadBuffer, 0, ReadPointer)); this.setHeaderPrarm(this.HeaderOri); while (ReadPointer <= (theFile.Length - 10)) { uint StartAddress = 0; for (int i = 0; i < 4; i++) { StartAddress = StartAddress + (uint)(theFile.ReadByte() << ((3 - i) * 8)); ReadPointer++; } uint Length = 0; for (int i = 0; i < 4; i++) { Length = Length + (uint)(theFile.ReadByte() << ((3 - i) * 8)); ReadPointer++; } if (Length > (theFile.Length - ReadPointer - 2)) { throw new Exception("Next VDF Block Lenth Error, Import Stop"); } else { byte[] VDFData = new byte[Length + 10]; Library.intToByte(StartAddress, 4).CopyTo(VDFData, 0); Library.intToByte(Length, 4).CopyTo(VDFData, 4); //Read VDFData WritePointer = 8; for (ulong i = 0; i < Length; i++) { VDFData[WritePointer] = (byte)theFile.ReadByte(); ReadPointer++; WritePointer++; } //Read VDFCheckSum; for (int i = 0; i < 2; i++) { VDFData[WritePointer] = (byte)theFile.ReadByte(); ReadPointer++; WritePointer++; } VBFBlock theVBFBlock = new VBFBlock(); bool VBFImportResult = theVBFBlock.ImportBlock(VDFData, this.DataFormatIdentifier); if (VBFImportResult) { this.DataBlocks.Add(theVBFBlock); } else { ImportResult = ImportResult + "Block " + this.DataBlocks.Count.ToString() + " Import Error. Checksum Read: " + Library.FormatUintToHex(theVBFBlock.CheckSum, 4) + "; Checsum Calculate: " + Library.FormatUintToHex(theVBFBlock.GenerateCRC(), 4) + "\r\n"; if (isForceImport) { Result = false; this.DataBlocks.Add(theVBFBlock); } else { throw new Exception(); } } } } theFile.Close(); } catch(Exception Error) { ImportResult = ImportResult + Error.Message + "\r\n"; Result = false; } return Result; }