Results 1 to 6 of 6

Thread: Opening files in webbrowser

  1. #1

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    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

    Parksie

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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.

  3. #3

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Resolved Re: Opening files in webbrowser

    Thanks keinma.
    Last edited by venerable bede; Aug 1st, 2008 at 05:16 AM.

    Parksie

  4. #4
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    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
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  5. #5

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    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

    Parksie

  6. #6
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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
  •  



Click Here to Expand Forum to Full Width