FileExtension–idea- part 1
Every now and then we accept file uploads ( to a site ) – or we have files in outlook that we want to open – but we do not know if the extension matches the content of the file.
There are numerous way to do it , however , I have been attracted by Magic Numbers – a header into the file that says what is the kind of the file.
For example, a .sln file has always those characters inside:
Microsoft Visual Studio Solution File, Format Version
You can then recognize if it is a real sln if it contains those characters.
Reading more on the internet, I have found
https://www.garykessler.net/library/file_sigs.html
https://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_numbers_in_files
https://en.wikipedia.org/wiki/List_of_file_signatures
Now, there are multiple programs and sites to do this magic number verifier – however, in order to practice programming, is always a good idea to start somewhere – so let’s see where it goes.
You can find the sources at https://github.com/ignatandrei/fileExtension/
The application is live at https://fileextension.azurewebsites.net/static/v1
You can find a NuGet package at https://www.nuget.org/packages/FileExtension/
Leave a Reply