Walter.IO
CountPaddingBytesChunked Method
Example 
Walter.IO Assembly > Walter.IO Namespace > FileInfoExtensions Class : CountPaddingBytesChunked Method
The file to inspect.
The size of the chunks to read in bytes. The default is 4096 bytes, chosen to balance efficiency and memory usage.
Reads the amount of padding at the end of a disk file.
Syntax
public static long CountPaddingBytesChunked( 
   FileInfo file,
   long chunkSize
)

Parameters

file
The file to inspect.
chunkSize
The size of the chunks to read in bytes. The default is 4096 bytes, chosen to balance efficiency and memory usage.

Return Value

The number of padding bytes found at the end of the file.
Exceptions
ExceptionDescription
Thrown if the file argument is null.
Thrown if the file does not exist.
If the file does not exists
If fileis null
Example
Calculate the percentage of the file that is padding:
FileInfo file = new FileInfo(@"path\to\your\file.ext");
long paddingBytes = file.CountPaddingBytesChunked();
Console.WriteLine($"The file contains {paddingBytes * 100.0 / file.Length:0.0}% padding bytes at the end.");
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

FileInfoExtensions Class
FileInfoExtensions Members