I am reading in a file, encrypting the contents, and writing the cipher text back out to a file using PowerShell. When the FileStream object ($inFS) is closed, it creates a file in the pwd (C:\docs) named "0". I opened the file and it had "32" written to it.
The encrypted contents are being written to a file in a different directory with no problems. I thought maybe there was something in the buffer still so I tried Flush() and Dispose() but same results. Why is this?
$inFile = 'C:\docs\algorithm_fsa.c'
$inFS = New-Object FileStream($inFile, [FileMode]::Open)
DO
{
$count = $inFS.Read($data, 0, $blockSizeBytes)
$offset += $count
$outStreamEncrypted.Write($data, 0, $count)
$bytesRead += $blockSizeBytes
}While($count > 0)
$inFS.Close()