A collection of minimal binary files.
See Milestones for release notes.
Entity Framework Extensions is a major sponsor and is proud to contribute to the development this project.
All files: https://github.com/VerifyTests/EmptyFiles/tree/main/files
- .7z (32 bytes)
- .7zip (32 bytes)
- .bz2 (14 bytes)
- .bzip2 (14 bytes)
- .gz (20 bytes)
- .gzip (20 bytes)
- .kmz (204 bytes)
- .nupkg (258 bytes)
- .tar (1 KB)
- .xz (32 bytes)
- .zip (22 bytes)
- .docx (810 bytes)
- .odt (647 bytes)
- .pdf (212 bytes)
- .rtf (6 bytes)
- .avif (70 bytes)
- .bmp (58 bytes)
- .dds (132 bytes)
- .dib (58 bytes)
- .emf (132 bytes)
- .exif (139 bytes)
- .gif (28 bytes)
- .heic (32 bytes)
- .heif (32 bytes)
- .ico (68 bytes)
- .j2c (44 bytes)
- .jfif (139 bytes)
- .jp2 (77 bytes)
- .jpc (44 bytes)
- .jpe (139 bytes)
- .jpeg (139 bytes)
- .jpg (139 bytes)
- .jxr (48 bytes)
- .pbm (8 bytes)
- .pcx (129 bytes)
- .pgm (10 bytes)
- .png (67 bytes)
- .ppm (12 bytes)
- .rle (58 bytes)
- .tga (21 bytes)
- .tif (198 bytes)
- .tiff (198 bytes)
- .wdp (48 bytes)
- .webp (26 bytes)
- .wmp (48 bytes)
- .gpkg (5 KB)
- .mbtiles (2 KB)
- .pmtiles (130 bytes)
- .shp (100 bytes)
- .shx (100 bytes)
- .ods (683 bytes)
- .xlsx (1.4 KB)
- .odp (667 bytes)
- .pptx (842 bytes)
- .bin (0 bytes)
Files can be consumed as a web resource using the following url:
https://github.com/VerifyTests/EmptyFiles/raw/main/index/empty.{extension}
So for example to consume a jpg use
https://github.com/VerifyTests/EmptyFiles/raw/main/index/empty.jpg
A 404 will result for non-existent files.
Ensure dotnet CLI is installed.
Install EmptyFiles.Tool
dotnet tool install -g EmptyFiles.Tool
emptyfile bmp
Creates {CurrentDirectory}/empty.bmp
emptyfile myfile.bmp
Creates {CurrentDirectory}/myfile.bmp
emptyfile path/myfile.bmp
Creates path/myfile.bmp
Creates a new empty file
AllFiles.CreateFile(pathOfFileToCreate);
Throws an exception if the extension is not known. There is also a TryCreateFile that will return false if the extension is not known.
Use the optional useEmptyStringForTextFiles to create a empty text file if the extension is text. The file will be UTF8 no BOM as per https://www.unicode.org/versions/Unicode5.0.0/ch02.pdf "Use of a BOM is neither required nor recommended for UTF-8".
Gets the path to an empty file for a given extension
var path = AllFiles.GetPathFor(".jpg");
Throws an exception if the extension is not known. There is also a TryGetPathFor that will return false if the extension is not known.
Returns true if the target file is an empty file.
var path = AllFiles.GetPathFor(".jpg"); await Assert.That(AllFiles.IsEmptyFile(path)).IsTrue(); var temp = Path.GetTempFileName(); await Assert.That(AllFiles.IsEmptyFile(temp)).IsFalse();
Enumerates all empty files
foreach (var path in AllFiles.AllPaths) { Trace.WriteLine(path); }
Use or replace a file
AllFiles.UseFile(Category.Document, pathToFile); await Assert.That(AllFiles.DocumentPaths.Contains(pathToFile)).IsTrue();
https://github.com/sindresorhus/text-extensions/blob/master/text-extensions.json
await Assert.That(FileExtensions.IsTextFile("file.txt")).IsTrue(); await Assert.That(FileExtensions.IsTextFile("file.bin")).IsFalse(); await Assert.That(FileExtensions.IsTextExtension(".txt")).IsTrue(); await Assert.That(FileExtensions.IsTextExtension(".bin")).IsFalse(); await Assert.That(FileExtensions.IsTextExtension("txt")).IsTrue(); await Assert.That(FileExtensions.IsTextExtension("bin")).IsFalse();
FileExtensions.AddTextExtension(".ext1"); await Assert.That(FileExtensions.IsTextExtension(".ext1")).IsTrue(); await Assert.That(FileExtensions.IsTextFile("file.ext1")).IsTrue();
FileExtensions.AddTextExtension(".ext1"); await Assert.That(FileExtensions.IsTextExtension(".ext1")).IsTrue(); FileExtensions.RemoveTextExtension(".ext1"); await Assert.That(FileExtensions.IsTextExtension(".ext1")).IsFalse();
AddTextFileConvention allows the use of a convention based text file detection via a callback.
At app startup add a convention using FileExtensions.AddTextFileConvention:
[ModuleInitializer] public static void AddTextFileConvention() => // Treat files ending with .txtViaConvention as text files FileExtensions.AddTextFileConvention(path => path.EndsWith(".txtViaConvention"));
Then any call to FileExtensions.IsTextFile will, in addition to checking the known text extensions, also check if any of the added text contentions return true.
await Assert.That(FileExtensions.IsTextFile("c:/path/file.txtViaConvention")).IsTrue();
An alternative approach to a text file convention would be to check if a file has a preamble that matches an known text encoding.
Hollow designed by Michael Senkow from The Noun Project.

