Hi,
When I used the following code to read a workbook, copy contents from another workbook, and save to the original file path. I noticed a System.IO.IOException about file access happened randomly.
Code:
var workbookPath = @"C:\test.xlsx"; var workbook2path = @"C:\test2.xlsx"; // can be replicable with this code for (int i = 0; i < 1000; ++i) { var workbook = new Workbook(workbookPath); var workbook2 = new Workbook(workbook2path); workbook2.Copy(workbook); workbook2.Save(workbook2.FileName); // fail randomly } // ... or this loop for (int i = 0; i < 1000; ++i) { var workbook = new Workbook(workbookPath); Workbook workbook2; using (var outStream = new FileStream(workbook2path, FileMode.OpenOrCreate)) workbook2 = new Workbook(outStream); workbook2.Copy(workbook); workbook2.FileName = workbook2path; workbook2.Save(workbook2.FileName); // fail randomly }
After a couple of iterations on either of the above loops, it will throw a System.IO.IOException about file access:
image.png (19.9 KB)
I’ve attached the test files for your reference. Could you help me check what went wrong here?
test.zip (21.1 KB)
Thanks,