短いコードを作成したところ、次の例外が発生しました。
ハンドルは同期操作をサポートしていません。FileStream コンストラクターへのパラメーターを変更して、ハンドルが非同期で開かれた (つまり、オーバーラップ I/O のために明示的に開かれた) ことを示す必要がある場合があります。
コードは次のようなものです。
byte[] filebytes = File.ReadAllBytes(filepath);
List<byte> codedbytes = new List<byte>();
byte constbyte = 240;
int blocksize = 67108864;
int counter = 0;
List<int> tempindex = new List<int>();
int index = 0;
private void DoTheJob()
{
[...]
for (int i = 0; i < filebytes.Length; i++,counter++)
{
codedbytes.AddRange(BitConverter.GetBytes(Convert.ToChar((filebytes[i] * constbyte))));
if (counter == blocksize)
{
FileStream tempwriter = File.Create(startdir + "\\temp" + index.ToString() + ".file");
for (int x = 0; x < codedbytes.Count; x++)
{
tempwriter.WriteByte(codedbytes[x]);
}
tempwriter.Close();
codedbytes.Clear();
counter = 0; tempindex.Add(index); index++;
}
}
[...]
for (int x = 0; x < tempindex.Count; x++)
{
▉Exception at this line▉▶ codedbytes = new List<byte>(File.ReadAllBytes(startdir + "\\temp" + tempindex[x].ToString() + ".file"));
[...]
}
}
FileStrem クラスにはオーバーロードされたコンストラクターがなく、すべてのオブジェクトを閉じたため、何が問題なのかわかりません。
正しい道を教えてください!