コードをバッチとして実行しているときに、コードで自分で作成したばかりのファイルを移動しようとすると、 「 System.IO.IOException: The process cannot access the file because it is being used by another process 」というエラーが表示されます。クライアントとして実行しても問題ありません。私はグーゲリングを試しましたが、提案のいくつかは含まれています。以下ですが、うまくいかなかったのでコメントを外しました。(filenameOutTemp は私がアクセスできないものです)
...
asciiIoOut = new AsciiIo(filenameOutTemp, #io_append);
asciiIoOut.outFieldDelimiter(#fieldDelimiter);
if (createFile)
{
// Replace the vend account from DDD with local:
record = conpoke(record, colVendDDD, vendSetupDDD.VendAccount);
asciiIoOut.writeExp(record);
}
}
//CodeAccessPermission::revertAssert();
asciiIoOut.finalize();
asciiIoOut = null;
//Move from temp folder to vender item folder:
fshVendTable = RetailVendTable::find(vendSetupDDD.VendAccount);
filenameOut = fshVendTable.filePathImport(VendorFileImportPath::Items);
filenameOut += #filePathSeperator + substr(inventImportFiles.Filename,1, strLen(inventImportFiles.Filename) - 4 );
filenameOut += #spacer + #item + #spacer + filenameDate + #spacer + filenameTime + #csv;
//new InteropPermission(InteropKind::ClrInterop).assert(); // get dll interop permission
try {
System.IO.File::Move(filenameOutTemp, filenameOut);
}
catch(Exception::Error) {
warning("move failed");
}
誰かが助けてくれることを願っています:)