|
-
Jul 31st, 2008, 10:01 AM
#1
Thread Starter
Fanatic Member
Opening files in webbrowser
I have a web browser control which I load with a variety of word docs.
If I do the following :
Code:
webBrowser1.Navigate(Application.StartupPath + "\\" + filename_A);
Then
Code:
webBrowser1.Navigate(Application.StartupPath + "\\" + tempFileNam_B);
System.IO.File.Delete(filename_A);
I always get the error/Exception
"The process cannot access the file because it is being used by another process."
How can I clear this up ? Is there any way to unlock the file after loading a new file ?
Thanks In Advance All
-
Jul 31st, 2008, 10:16 AM
#2
Re: Opening files in webbrowser
vene,
Your issue is that you are trying to delete file A immediately when you navigate to file B, and file A hasn't been closed at that point.
What you need to do, is use the DocumentCompleted event of the browser to be your indicator that the doc has fully loaded. at that point delete file A.
The only problem you may have, is I don't think the "temp" doc files (the ones that hold edits until you save) get deleted when you do what you are doing.
-
Aug 1st, 2008, 04:06 AM
#3
Thread Starter
Fanatic Member
Re: Opening files in webbrowser
Last edited by venerable bede; Aug 1st, 2008 at 05:16 AM.
-
Aug 1st, 2008, 04:34 AM
#4
Re: Opening files in webbrowser
go up to the top of the thread and on the left you will see a menu item named Thread Tools, just click that and then go to Mark Thread Resolved
-
Aug 1st, 2008, 05:15 AM
#5
Thread Starter
Fanatic Member
Re: Opening files in webbrowser
Actually after further testing I have discovered that it doesn't work.
I cannot delete the file because a Microsoft Word process is still running and keeping the files locked.
Bum....this is driving me nuts
-
Aug 1st, 2008, 08:26 AM
#6
Re: Opening files in webbrowser
vene, can you post your code, or at least a sample that does the same thing? I did test, and didn't have problems. Once documentcompleted fires for the SECOND doc you open, the reference to the first doc should be gone, and you should be able to delete the file from the disk.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|