Skip to content
Max Vasilyev edited this page Apr 3, 2017 · 1 revision

Project is a library of functions.

Then in every class where you need to use FileDetective add reference to the library:

using FileTypeDetective;

This will provide a list of extension functions for FileInfo objects. The usage is as following:

FileInfo file = new FileInfo("C:\tmp\unknown.file");

// returns file type - one of the contants defined in the class
FileType type = file.GetFileType();

// writes the file extension
Console.WriteLine(type.ToString());

// compares if the file belongs to some type
if (type.isType(FileTypeDetective.WORD))
{
   Console.WriteLine("File is MS Word");
}

// returns true if the file is PDF
if (type.isPdf()){
   Console.WriteLine("Pdf");
}
Clone this wiki locally