WebBrowser problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using the AxSHDocVw.AxWebBrowser control (named PreviewBrowser) in my C#
app to load a pdf file:

PreviewBrowser.Navigate(strPDF ,ref objNull,ref objNull,ref objNull,ref
objNull);
These PDF files are created and stored in a temp folder. The older files
from temp need to be deleted everytime prior to calling the Navigate function
for the current file.

But I am getting an exception when i try to delete the temp folder
(containing the older pdf files)
"The process cannot access the file "xxx.pdf" because it is being used by
another process."

Is there any property/setting for the WebBrowser control to free up the file??
 
Just a suggestion, use System.Net.WebClient instead of
AxSHDocVw.AxWebBrowser.

Otherwise, try performing an Application.DoEvents() loop until the
document's readyState is Complete. Not sure if that works or not.

Jon
 
Jon,

We are using AxSHDocVw.AxWebBrowser extensively in our app, so using another
browser component is not an option.
Application.DoEvents() doesn't work.

Thanks for the suggestions.
 
We are using AxSHDocVw.AxWebBrowser extensively in our app, so using
another
browser component is not an option.

System.Net.WebClient is not a browser component. It just performs an HTTP
query to fetch the document and put the file wherever you want it. I use
AxSHDocVw.AxWebBrowser, too, but for situations similar to yours there is no
harm in using other components.

If the user is clicking on the a link to the odcument, use the
DownloadComplete event. If you're using .NET 2.0, try using the
System.Windows.Forms.WebBrowser, which is a wrapper of
AxSHDocVw.AxWebBrowser, and then use the DocumentStream property after
DocumentComplete event finishes to read the stream out to a file, or look
for the DocumentStream equivalent in AxSHDocVw.AxWebBrowser.

Jon
 
Back
Top