Solved

Modify file displayed in AxSHDocVw.AXWebBrowser

Posted on 2006-07-11
11
372 Views
Last Modified: 2012-06-21
Hi,
I am working on a vb.net windows application. (windows 2000 / .net 1.1)

I have an issue with the webbrowser control (AxSHDocVw.AXWebBrowser).
The webbrowser control contains an html page loaded from local disk. However when I try to modify the html file (in Notepad or whatever) I get this error:
    "The process cannot access the file because it is being used by another process."

How can I modify the html file while it is in the web browser control??
Thanks
0
Comment
Question by:gjok
  • 5
  • 5
11 Comments
 
LVL 5

Expert Comment

by:vinodhsomasekharan
ID: 17080873
I can not get any problems :(
Can u post your code ?

regards
vinu
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17082070
1) .NET version?  2002, 2003, or 2005?

2) What are you trying to accomplish here?

Bob
0
 
LVL 2

Author Comment

by:gjok
ID: 17084989
Bob, Not sure about the year (2003 ??). I'm using .NET Framework version 1.1

What I have is a windows form containing a web browser control called AxWebBrowser1.
AxWebBrowser1 contains an htm file which is located on the local disk (C:).

If I open and modify the htm file in notepad, I cant save it due to a sharing violation:
   "The process cannot access the file because it is being used by another process."

vinu,
There isnt any code yet, except for:
AxWebBrowser1.Navigate(MyUrl)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 96

Expert Comment

by:Bob Learned
ID: 17085824
I ran a test with AxWebBrowser and this code:

   Me.AxWebBrowser1.Navigate("file://c:\temp\temp.html")

It let me open the file in Notepad and save it.  What does your URL look like?

Bob
0
 
LVL 2

Author Comment

by:gjok
ID: 17086301
Mine's the same format - looks like this:
AxWebBrowser1.Navigate("file://" & App_Path & "\reports\492.htm")

I've tried different drives and folders, also to no avail.
Security on the htm file is set to "Everyone", full control.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17086317
What are the rights for the folder?  Rights are cumulative and are the most restrictive settings, so if you have defined rights at a higher level, there is a set of effective rights.

Bob
0
 
LVL 2

Author Comment

by:gjok
ID: 17086443
I'm no expert on security, but I dont think that it. I've been trying many folders that I use regularly, as well as new test folders.
The original htm file was created manually. I've since also tried creating and reloading the file programatically from the actual application itself.
I am only able to save the htm file when I stop debugging.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17086458
Well, I can't look over your shoulder and figure this one out, so I am depending on you to describe your environment as fully as possible.  There is always the FileMon utility from Sysinternals.

Bob
0
 
LVL 2

Author Comment

by:gjok
ID: 17086519
Hang on - I've found the problem - I still dont know how to resolve it though..

Another piece of code is running in the same sub that loads the htm file. When I comment it out it works. So it looks like the commented code (below) is still keeping the file/stream open.
How do I close the stream?

    'Dim MyUrl As String = "file://" & App_Path & "\reports\492.htm"
    'Dim req As WebRequest = WebRequest.Create(MyUrl)
    'Dim resp As WebResponse = req.GetResponse()

    'Dim s As Stream = resp.GetResponseStream()
    'Dim sr As StreamReader = New StreamReader(s, Encoding.ASCII)
    'Dim doc As String = sr.ReadToEnd()

    AxWebBrowser1.Navigate("file://" & App_Path & "\reports\492.htm")
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 125 total points
ID: 17086539
1) If this is a file on your local drive, and not across the Internet, then the WebRequest is not needed.

2) If you are using a WebBrowser to navigate to the file, then again the WebRequest is not needed.

3) So, given all that, why are you using it?

Bob
0
 
LVL 2

Author Comment

by:gjok
ID: 17086692
I was planning to parse bits of the htm file for certain values, for use in the programs Form (i.e labels).
However, I could access this data another way.

Thank you!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question