Error opening/displaying exported SpreadDocument

1 Answer 10 Views
SpreadProcessing SpreadStreamProcessing
Debra
Top achievements
Rank 1
Iron
Debra asked on 09 Apr 2024, 06:30 PM

I'm able to export data to an .xlsx file.  That file is exported to E:/SaoApps/Sims/wwwroot/exports and the user has full control over that folder.  The file successfully is created at that location.  But the file doesn't open or offer download to the user and the error message is:

In the attached code snippet, the passed exportsFolder = "E:/SaoApps/Sims/wwwroot/exports/" and passed lanId = "DSS"

"An error occurred trying to start process 'E:/SaoApps/Sims/wwwroot/exports/ContactsSearchResults_DSS.xlsx' with working directory 'E:\\Workspace\\Intranet\\Sims\\Sims'. The process cannot access the file because it is being used by another process."

 

System.ComponentModel.Win32Exception (32): An error occurred trying to start process 'E:/SaoApps/Sims/wwwroot/exports/ContactsSearchResults_DSS.xlsx' with working directory 'E:\Workspace\Intranet\Sims\Sims'. The process cannot access the file because it is being used by another process.
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   at Sims.Agency.Data.Services.AgencyExportService.ExportContactSearchResults(String criteria, List`1 searchResults) in E:\Workspace\Intranet\Sims\Sims.Agency.Data\Services\AgencyExportService.cs:line 424
   at Sims.Contacts.Pages.ContactSearchBase.ExportToExcel() in E:\Workspace\Intranet\Sims\Sims.Contacts\Pages\ContactSearchBase.cs:line 327
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

1 Answer, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 12 Apr 2024, 09:30 AM

Hello Debra,

I was able to reproduce the exception you are experiencing and setting the UseShellExecute to true seems to resolve the issue.

//The code succeeds to this point.
ProcessStartInfo psi = new ProcessStartInfo()
{
    FileName = "..\\..\\..\\output.xlsx",
    UseShellExecute = true
};
Process.Start(psi);

If you haven't already please give this a try. I hope it helps.

Regards,
Yoan
Progress Telerik

A brand new ThemeBuilder course was just added to the Virtual Classroom. The training course was designed to help you get started with ThemeBuilder for styling Telerik and Kendo UI components for your applications. You can check it out at https://learn.telerik.com
Tags
SpreadProcessing SpreadStreamProcessing
Asked by
Debra
Top achievements
Rank 1
Iron
Answers by
Yoan
Telerik team
Share this question
or