private void TestValid() { int i = 0; byte[] b = null; BinaryReader m_br; m_br = new BinaryReader(new FileStream(sFileName, FileMode.Open, FileAccess.Read)); WMUtils.WMValidateData(b, ref i); b = new byte[i]; m_br.Read(b, 0, i); WMUtils.WMValidateData(b, ref i); try { b[0] = 55; WMUtils.WMValidateData(b, ref i); Debug.Assert(false); } catch (Exception e) { int hr = Marshal.GetHRForException(e); Debug.Assert(hr == NSResults.E_INVALID_NAME); } }
public void isValid(string filename) { int pdwDataSize = 0; WMUtils.WMValidateData(null, ref pdwDataSize); byte[] data = new byte[pdwDataSize]; using (FileStream s = new FileStream(filename, FileMode.Open, FileAccess.Read)) { if (s.Read(data, 0, pdwDataSize) < pdwDataSize) { throw new Exception("partial read"); // TODO } } WMUtils.WMValidateData(data, ref pdwDataSize); }