FileStream can't access the file because it's being used by another process

后端 未结 2 1450
-上瘾入骨i
-上瘾入骨i 2021-01-20 16:12

I\'m new at web app in ASP.NET and I came across this problem.

I have a page whe there is a Button to download a template.xls that is previously stored at a SharePoi

相关标签:
2条回答
  • 2021-01-20 16:39

    i have solved this problem by another way

    i open Window Task Manager and find that my dll file of my project is running

    multiples ( i mean copy of it exists) i remove them and than my problem is solved

    0 讨论(0)
  • 2021-01-20 16:51

    From what I can tell, you're opening the file-stream, and then trying to open it again, before you close it.

    Initial opening of the file:

    FileStream _FileStream = new FileStream(apPath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
    

    and

    Response.TransmitFile(apPath); 
    

    seems to be trying to open the file again.

    I would suggest calling

    _FileStream.Close();
    

    before calling TransmitFile.

    0 讨论(0)
提交回复
热议问题