public void Open(string filename) { Release(); capture.ptr = IntPtr.Zero; asImage = null; string ext = System.IO.Path.GetExtension(filename); // if the extension of the filename is not AVI, try opening as an image. if (ext.ToUpper().CompareTo(".AVI") != 0) { asImage = new CVImage(filename); } else { capture = PInvoke.cvCreateFileCapture(filename); CVUtils.CheckLastError(); if (capture.ptr == IntPtr.Zero) { throw new CVException( string.Format("Unable to open file '{0}' for capture.", filename)); } } this.filename = filename; }