WebBrowser problem

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??
 
J

Jon Davis

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
 
G

Guest

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.
 
J

Jon Davis

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top