Link to home
Start Free TrialLog in
Avatar of gjok
gjokFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Modify file displayed in AxSHDocVw.AXWebBrowser

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
Avatar of vinodhsomasekharan
vinodhsomasekharan

I can not get any problems :(
Can u post your code ?

regards
vinu
Avatar of Bob Learned
1) .NET version?  2002, 2003, or 2005?

2) What are you trying to accomplish here?

Bob
Avatar of gjok

ASKER

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)
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
Avatar of gjok

ASKER

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.
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
Avatar of gjok

ASKER

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.
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
Avatar of gjok

ASKER

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")
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gjok

ASKER

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!