So I'm trying to fill a media device in increments and measure the speed, and it works until I go to write data from 75% to 95% (We don't completely fill it)
When I go to set the file length (Ex: I'm trying to make a 3.1GB file when the disk has 3.72 GB available I get the following exception
"The parameter is incorrect."
StackTrace
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.SeekCore(Int64 offset, SeekOrigin origin)
at System.IO.FileStream.SetLengthCore(Int64 value)
at System.IO.FileStream.SetLength(Int64 value)
at DiskSpeed.Write.WriteFileFromMemory(Byte[] buffer, String path, Int64 fileSize, Int32 currentIteration, Int32 totalIterations, CancellationToken ct)
Here's the code
using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None, 8, FileOptions.WriteThrough | FileFlagNoBuffering))
{
fs.SetLength(fileSize);
.......
}
I'm using this to write chunks to a removalable media in increments of 25%, but after 75%, I only write a 20% chunk. Going from 0-75% works fine, it's the final chunk that throws this error. Yes, I have double checked the file size, THERE IS SPACE!!!
Does anyone have any ideas? I'm at my wits end and I can't seem to find anything online.