StreamReaderとStreamWriterを使用してバイナリファイルを読み書きした場合、ファイルを修復できますか?
// Original Code - Corrupted the Destination File
using (Stream responseStream = response.GetResponseStream())
{
using (StreamReader reader = new StreamReader(responseStream))
{
using (StreamWriter writer = new StreamWriter(destinationFileName, false))
{
writer.Write(reader.ReadToEnd());
}
}
}
// New Code - Destination File is Good
using (Stream responseStream = response.GetResponseStream())
{
using (FileStream fs = File.Create(destinationFileName))
{
responseStream.CopyTo(fs);
}
}