Skip to content

ignatandrei/FileExtension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FileExtension

GitHub repo Questions at StackOverflow Ask a question at StackOverflow Community discussions License codecov Nuget .NET Docs Maintainability Rating

What it does

This project helps you to see that a file has the correct extension

What it recognize

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

How to use it

Demo online: https://fileextension.azurewebsites.net/swagger/index.html

NuGet Package: Nuget

Simple use

.NET / C#

Add a reference to Nuget ,

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}");
}

Angular / TypeScript

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

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Andrei Ignat

⚠️ 💻

This project follows the all-contributors specification. Contributions of any kind welcome!

Links

Licence

The code in this project is licensed under MIT license.