VersionZiper/SevenZip/FileSignatureChecker.cs
/// <summary>
/// Gets the InArchiveFormat for a specific file name.
/// </summary>
/// <param name="fileName">The archive file name.</param>
/// <param name="offset">The archive beginning offset.</param>
/// <param name="isExecutable">True if the original format of the file is PE; otherwise, false.</param>
/// <returns>Corresponding InArchiveFormat.</returns>
/// <exception cref="System.ArgumentException"/>
Gets the InArchiveFormat for a specific file name.
Gets the InArchiveFormat for a specific file name .
public static InArchiveFormat CheckSignature(string fileName, out int offset, out bool isExecutable)
        {
            using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                try
                {
                    return CheckSignature(fs, out offset, out isExecutable);
                }
                catch (ArgumentException)
                {
                    offset = 0;
                    isExecutable = false;
                    return Formats.FormatByFileName(fileName, true);
                }
            }
        }
public static InArchiveFormat CheckSignature ( string fileName , out int offset , out bool isExecutable ) { using ( var fs = new FileStream ( fileName , FileMode . Open , FileAccess . Read , FileShare . ReadWrite ) ) { try { return CheckSignature ( fs , out offset , out isExecutable ) ; } catch ( ArgumentException ) { offset = 0 ; isExecutable = false ; return Formats . FormatByFileName ( fileName , true ) ; } } }
Gets the InArchiveFormat for a specific file name.
Gets the InArchiveFormat for a specific file name .
None
None
fileName
string
The archive file name.
The archive file name .
int
out
bool
out
offset
The archive beginning offset.
The archive beginning offset .
isExecutable
True if the original format of the file is PE; otherwise, false.
True if the original format of the file is PE ; otherwise false .