This project helps you to see that a file has the correct extension
There are 344 extensions of files ( 16 tested) . See https://fileextension.readthedocs.io/en/latest/BDD/LightBDDReport/
Please help by making a PR by adding files to https://github.com/ignatandrei/FileExtension/tree/master/src/TestFileExtensions/TestFiles
Demo online: https://fileextension.azurewebsites.net/swagger/index.html
var r = new RecognizerPlugin.RecognizePlugins();
//foreach (var item in r.AllExtensions())
//{
// Console.WriteLine(item);
//}
//find the sln on the path
string file = FindSlnToBeRecognized();
//found sln, now recognize
var byts = await File.ReadAllBytesAsync(file);
//find short way - directly
var foundDirectly = r.Is_SLN(byts);
Console.WriteLine($"file {file} is recognized {foundDirectly}");
// or long way
//find extension
var fileExtension = Path.GetExtension(file);
// find if there is a recognizer for the extension
var canRecognize = r.CanRecognizeExtension(fileExtension);
Console.WriteLine($"file {file} can be recognized {canRecognize}");
if (canRecognize)
{
//now see if the content matches the bytes
var found = r.RecognizeTheFile(byts, fileExtension);
Console.Write($"file {file} is recognized {found}");
}
For calling the service , please see https://github.com/ignatandrei/FileExtension/blob/master/src/FileExtensionAng/src/app/services/FileExtv1.service.ts
For a component, please see https://github.com/ignatandrei/FileExtension/tree/master/src/FileExtensionAng/src/app/file-ext-v1
Thanks goes to these wonderful people (emoji key):
Andrei Ignat |
This project follows the all-contributors specification. Contributions of any kind welcome!
- Project homepage: https://github.com/ignatandrei/FileExtension/
- Code Coverage: https://codecov.io/gh/ignatandrei/FileExtension
- Results of tests in BDD format : https://record-visitors.readthedocs.io/en/latest/BDD/LightBDDReport/
- Code analysis: https://sonarcloud.io/dashboard?id=ignatandrei_RecordVisitors
- Repository: https://github.com/ignatandrei/FileExtension/
- Issue tracker: https://github.com/ignatandrei/FileExtension/issues
- Documentation: https://fileextension.readthedocs.io/en/latest/
- Blog: http://msprogrammer.serviciipeweb.ro/category/FileExtension/
The code in this project is licensed under MIT license.