Solved

Modify file displayed in AxSHDocVw.AXWebBrowser

Posted on 2006-07-11
11
335 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
 
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now