Solved

Modify file displayed in AxSHDocVw.AXWebBrowser

Posted on 2006-07-11
11
364 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

792 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