Completed
Last Updated: 14 May 2024 15:37 by ADMIN
Release 2024.2.514 (2024 Q2)
Philipp
Created on: 21 Jan 2019 10:37
Category: PDFViewer
Type: Bug Report
3
PdfViewer: Uncaught exception while saving

When using SaveAsCommandDescriptor of RadPdfViewer and trying to replace a pdf file that is currently open in adobe reader causes the following exception:

 

System.IO.IOException: The process can not access file "C:\Temp\test.pdf" because it used by another process.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
   at Microsoft.Win32.SaveFileDialog.OpenFile()
   at Telerik.Windows.Documents.Commands.SaveAsPdfDocumentCommand.Execute(Object parameter)
   at MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(ICommandSource commandSource, Boolean userInitiated)
   at System.Windows.Controls.Primitives.ButtonBase.OnClick()
   at System.Windows.Controls.Button.OnClick()
   at Telerik.Windows.Controls.RadButton.OnClick()
   at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   [...]
3 comments
ADMIN
Georgi
Posted on: 04 Feb 2019 10:26
Hello Philipp,

I am sorry for misunderstanding you in our previous answer. Indeed, you are right that System.IO.IOException should be handled in RadPdfViewer. I changed the status of the item and added vote on your behalf to increase its priority. In appreciation for pointing out this to our attention I have increased your Telerik points.

Regards,
Georgi
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Philipp
Posted on: 28 Jan 2019 11:08

Dear Tanya,

thanks for your answer. I know how to handle this in my own code but this issue happens when using the save button of the RadPdfViewerToolBar. This means there is just telerik code involved to crash the application.

To replicate the issue you just need to create a sample application containing a RadPdfViewer with a RadPdfViewerToolBar. Then open a pdf file in the telerik pdf viewer and (another) in adobe reader. Then press the save button of RadPdfViewerToolBar and try to replace the opened file.

Best regards,
Philipp

ADMIN
Tanya
Posted on: 28 Jan 2019 08:52
Hi Philipp,

When a PDF file is opened in Adobe, it is blocked for performing manipulations on it through other applications. That is why the file becomes inaccessible and it cannot be shared between the applications. In this case, the error you are getting is expected as the Stream cannot be opened. Here is a suggestion of how you could handle similar cases: https://www.codeproject.com/Questions/493093/c-23pluscheckingplusifplusaplusfileplusisplusalrea.

Regards,
Tanya
Progress Telerik
Get quickly and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.