//public static void WriteHexDumpFromFile(string filename) //{ // try // { // File file = new File(filename); // RandomAccessFile stream = new RandomAccessFile(file, "r"); // sbyte[] bytes = new sbyte[stream.length()]; // stream.read(bytes); // stream.close(); // System.Console.WriteLine("dump of [" + file + "]"); // Console.WriteHexDump(bytes); // } // catch (Exception exc) // { // Console.WriteThrowable(exc); // } //} /// <summary> /// writes bytes to file /// </summary> /// <param name="cdata"></param> /// <param name="p"></param> public static void WriteBytes(sbyte[] cdata, string filename, bool utf8) { try { File f = new File(filename); if (f.exists()) { f.delete(); } RandomAccessFile stream = new RandomAccessFile(filename, "rw"); if (utf8) { stream.writeByte(0xEF); stream.writeByte(0xBB); stream.writeByte(0xBF); } stream.write(cdata); stream.close(); } catch { } }
private void Write(int sectorNumber, byte[] data, int length) { _file.seek(sectorNumber * SectorBytes); _file.writeInt(length + 1); // chunk length _file.writeByte(VersionDeflate); // chunk version number _file.write(data, 0, length); // chunk data }
private void write(int i, byte[] abyte0, int j) { debugln((new StringBuilder()).append(" ").append(i).toString()); dataFile.seek(i * 4096); dataFile.writeInt(j + 1); dataFile.writeByte(2); dataFile.write(abyte0, 0, j); }