DEXTUpload.NET
Class FileSignatureAnalyzer
- The minimum supported version
- 5.2.0.0
- The minimum support environment
- .NET Framework 4.0
- Explanation
-
The "FileSignatureAnalyzer" is a class that can be used when trying to inspect file signatures manually.
File signature inspection is a different operation on the basis of the set value of <dextupload.net><settings methodFileSignatureChecking="..." .../> element of the "Web.config" file. File signature inspection is running in the "DEXTUpload.NET.FileUploadMonitorModule" module object, processing the same for all requests to upload files. If you want to run the file signature inspection directly in a page(aspx), a generic handler (ashx) or the MVC controller, you can use the "FileSignatureAnalyzer" class.
using (var dext = new FileUpload()) { // Create an instance of the "FileSignatureAnalyzer" class. var fsa = new FileSignatureAnalyzer(); var element = dext.GetSingleFileElement(); if (!element.IsEmpty) { // You can perform the check at the temporary file level before saving. var fsr = fsa.Check(element.FileExtension, element.TempFilePath); switch (fsr) { case FileSignatureResult.Absence: // There is no signature information of the extension. ... break; case FileSignatureResult.Different: // The file does not match the signature information. ... break; case FileSignatureResult.Same: // The file matches the signature information. break; } } }
- Type
-
public class FileSignatureAnalyzer
- Constructors
-
FileSignatureAnalyzer
-
Does initialization when creating an instance of the "FileSignatureAnalyzer" class.
When you create an object using the constructor with no parameters, the signature information using the resources contained within the component assembly. If you need to use another resource file, the constructor may be set to the path of the target file.
-
Type
public FileSignatureAnalyzer() public FileSignatureAnalyzer(strign signatureDataFilePath)
-
Parameters
Name Type Explanation signatureDataFilePath System.String It is the path(physical path) of the signature data file.
-
- Properties
-
VersionString
-
Gets a version of the signature data.
The version of the signature data file is updated each time the content is changed, it is possible to confirm the version with the "VersionString" property.
-
Type
public string VersionString { get; }
-
- Methods
-
Has
-
Returns whether or not to have a signature information corresponding to the specified extension name.
-
Type
public bool Has(string extension)
-
Parameters
Name Type Explanation extension System.String The name of the extension of the file. -
Return
If the signature information corresponding to the specified extension name, it is "true", otherwise, "false".
Check
-
Performs a signature inspection and returns the "DEXTUpload.NET.FileSignatureResult" value as a result.
-
Type
public FileSignatureResult Check(string filePath) public FileSignatureResult Check(string extension, string filePath) public FileSignatureResult Check(string extension, FileStream stream)
-
Parameters
Name Type Explanation filePath System.String It is the path(physical path) of the file to be tested. extension System.String The name of the extension to be inspected. stream System.IO.FileStream The "FileStream" object that was opened from a file to be examined. -
Return
Returns the "DEXTUpload.NET.FileSignatureResult" value as a test results.
-