This is a migrated thread and some comments may be shown as answers.
Dispose
1 Answer 3 Views
This is a migrated thread and some comments may be shown as answers.
Fit2Page
Top achievements
Rank 1
Fit2Page asked on 21 Mar 2018, 02:22 PM

How should I dispose the target object?

The file is kept locked...and cannot be accessed later by other code.

 Dim fileName As String = Server.MapPath("~/userfiles/file/excel/" & Session.SessionID & ".xlsx")

            Dim formatProvider As IWorkbookFormatProvider = New XlsxFormatProvider()

            Using output As New FileStream(fileName, FileMode.Create)
                formatProvider.Export(workbook, output)
            End Using

1 Answer, 1 is accepted

Sort by
0
Anna
Telerik team
answered on 26 Mar 2018, 10:25 AM
Hi,

The way the export is done here is correct and there shouldn't be anything additional needed for it to dispose the file stream properly. It seems to me that most likely there is something else in the application which is locking the file. In case you are unable to determine such a place and have a reason to think that the format provider is causing the lock, can you please prepare a sample project isolating the issue and send it our way? I am sure it can be a hassle to reproduce the server behavior, but it would indeed be of great help.

Regards,
Anna
Progress Telerik

Asked by
Fit2Page
Top achievements
Rank 1
Answers by
Anna
Telerik team
Share this question
or