Один процесс копирует файл в папку:
Код: Выделить всё
System.IO.File.Copy(fileNameDownload, path);
Код: Выделить всё
using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
var xlsxBook = new XSSFWorkbook(fs); // suddenly threw exception
var xlsBook = new HSSFWorkbook(fs);
}
Код: Выделить всё
Cannot access a closed file
at System.IO.__Error.FileNotOpen()
at System.IO.FileStream.Read(Byte[] array, Int32 offset, Int32 count)
at NPOI.Util.IOUtils.ReadFully(Stream stream, Byte[] b, Int32 off, Int32 len) in C:\github\npoi\main\Util\IOUtils.cs:line 179
at NPOI.POIFS.FileSystem.NPOIFSFileSystem..ctor(Stream stream) in C:\github\npoi\main\POIFS\FileSystem\NPOIFSFileSystem.cs:line 291
Подробнее здесь: https://stackoverflow.com/questions/787 ... immediatly