public virtual bool ImportRaw(string path) { byte[] raw = File.ReadAllBytes(path); if (raw == null) { return(Logger.Fail("File not found " + path)); } int len = GetLen(); byte[] buf = new byte[len]; if (len < raw.Length) { string msg = "Data will be truncated.\r\nProceed?"; if (!Logger.YesNoCancel(msg)) { return(false); } buf = raw; } else if (len > raw.Length) { string msg = "Data will be padded with zeroes.\r\nProceed?"; if (!Logger.YesNoCancel(msg)) { return(false); } raw.CopyTo(buf, 0); } else { buf = raw; } return(UndoRedo.Exec(new BindArray(this, GetPos(), len, buf))); }
private void SetTime(int delta, DateTime t) { int YYYY = t.Year; int MM = t.Month; int DD = t.Day; int hh = t.Hour; int mm = t.Minute; int ss = t.Second; int ms = t.Millisecond; byte[] buf = new byte[17] { (byte)((YYYY / 1000) % 10 + 0x30), (byte)((YYYY / 100) % 10 + 0x30), (byte)((YYYY / 10) % 10 + 0x30), (byte)((YYYY / 1) % 10 + 0x30), (byte)((MM / 10) % 10 + 0x30), (byte)((MM / 1) % 10 + 0x30), (byte)((DD / 10) % 10 + 0x30), (byte)((DD / 1) % 10 + 0x30), (byte)((hh / 10) % 10 + 0x30), (byte)((hh / 1) % 10 + 0x30), (byte)((mm / 10) % 10 + 0x30), (byte)((mm / 1) % 10 + 0x30), (byte)((ss / 10) % 10 + 0x30), (byte)((ss / 1) % 10 + 0x30), (byte)((ms / 100) % 10 + 0x30), (byte)((ms / 10) % 10 + 0x30), 0 }; UndoRedo.Exec(new BindArray(this, GetPos() + delta, 17, buf)); }