我收到错误“ System.IO.IOException: The process cannot access the file because it is being used by another process ”,同时尝试移动我刚刚在代码中创建的文件,同时将代码作为批处理运行。我作为客户端运行它没有问题。我尝试过 Googelling,其中一些建议包括在内。下面但未注释,因为它不起作用。(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");
}
希望有人可以帮忙:)