示例#1
0
        /// <summary>
        /// Determines whether a file, identified by a stream, is a cabinet file.
        /// </summary>
        /// <param name="fstream">The open file stream to be tested.</param>
        /// <param name="cabinfo">A <see cref="FdiCabinetInfo"/> object that will receive information about the cabinet file.</param>
        /// <returns>Returns True if the file is a cabinet.  If so, the cabinfo object is filled with information about the cabinet file.
        /// Returns False if the file is not a cabinet.</returns>
        public bool IsCabinetFile(Stream fstream, FdiCabinetInfo cabinfo)
        {
            if (disposed)
            {
                throw new ObjectDisposedException("CabDecompressor");
            }

            GCHandle gch = GCHandle.Alloc(fstream);
            try
            {
                return CabSdk.FdiIsCabinet(FdiContext, (IntPtr)gch, cabinfo);
            }
            finally
            {
                gch.Free();
            }
        }
示例#2
0
 public static extern bool FdiIsCabinet(
     IntPtr hfdi,
     IntPtr hf,
     FdiCabinetInfo cabInfo);
示例#3
0
        /// <summary>
        /// Determines whether a file, identified by a file name, is a cabinet file.
        /// </summary>
        /// <param name="filename">The name of the file to be tested.</param>
        /// <param name="cabinfo">A <see cref="FdiCabinetInfo"/> object that will receive information about the cabinet file.</param>
        /// <returns>Returns True if the file is a cabinet.  If so, the cabinfo object is filled with information about the cabinet file.
        /// Returns False if the file is not a cabinet.</returns>
        public bool IsCabinetFile(string filename, FdiCabinetInfo cabinfo)
        {
            if (disposed)
            {
                throw new ObjectDisposedException("CabDecompressor");
            }

            using (FileStream fs = File.Open(filename, FileMode.Open,
                       FileAccess.Read, FileShare.ReadWrite))
            {
                return IsCabinetFile(fs, cabinfo);
            }
        }