Web Browser control - how to navigate to a local file.

T

timnels

I have a web browser control that I'd like to point at a HTML file in
my installation directory. I am doing something like:

string path = Path.GetDirectoryName(
Assembly.GetExecutingAssembly().GetModules()
[0].FullyQualifiedName) +
"\\howdoi.htm";
webBrowser1.Navigate(path);

What do I need to do to form the correct URI string for a local file?

Thanks.
 
N

Nicholas Paldino [.NET/C# MVP]

Once you get the assembly for the executing assembly, you will want to
use the Location property on the assembly to get the directory that the
assembly is in.
 
T

timnels

Once you get the assembly for the executing assembly, you will want to
use the Location property on the assembly to get the directory that the
assembly is in.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


I have a web browser control that I'd like to point at a HTML file in
my installation directory. I am doing something like:
string path = Path.GetDirectoryName(
Assembly.GetExecutingAssembly().GetModules()
[0].FullyQualifiedName) +
"\\howdoi.htm";
webBrowser1.Navigate(path);
What do I need to do to form the correct URI string for a local file?

Thanks but the path comes out as C:\....\howdo.ihtm which is the
correct file name, but the Navigate method displays page not found
type error. Let's say I wanted to navigate to a local file C:\temp
\text.html.... what would I pass to navigate ?
 
N

Nicholas Paldino [.NET/C# MVP]

When you call navigate, it should take a file name just fine and
navigate to it. It it doesn't, then there is something else wrong (perhaps
the file name is wrong).


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Once you get the assembly for the executing assembly, you will want
to
use the Location property on the assembly to get the directory that the
assembly is in.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


I have a web browser control that I'd like to point at a HTML file in
my installation directory. I am doing something like:
string path = Path.GetDirectoryName(
Assembly.GetExecutingAssembly().GetModules()
[0].FullyQualifiedName) +
"\\howdoi.htm";
webBrowser1.Navigate(path);
What do I need to do to form the correct URI string for a local file?

Thanks but the path comes out as C:\....\howdo.ihtm which is the
correct file name, but the Navigate method displays page not found
type error. Let's say I wanted to navigate to a local file C:\temp
\text.html.... what would I pass to navigate ?
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi.
Thanks but the path comes out as C:\....\howdo.ihtm which is the
correct file name, but the Navigate method displays page not found
type error. Let's say I wanted to navigate to a local file C:\temp
\text.html.... what would I pass to navigate ?

Try it with IE, maybe you should use file://c:\......
 
T

timnels

When you call navigate, it should take a file name just fine and
navigate to it. It it doesn't, then there is something else wrong (perhaps
the file name is wrong).

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Once you get the assembly for the executing assembly, you will want
to
use the Location property on the assembly to get the directory that the
assembly is in.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I have a web browser control that I'd like to point at a HTML file in
my installation directory. I am doing something like:
string path = Path.GetDirectoryName(
Assembly.GetExecutingAssembly().GetModules()
[0].FullyQualifiedName) +
"\\howdoi.htm";
webBrowser1.Navigate(path);
What do I need to do to form the correct URI string for a local file?
Thanks.
Thanks but the path comes out as C:\....\howdo.ihtm which is the
correct file name, but the Navigate method displays page not found
type error. Let's say I wanted to navigate to a local file C:\temp
\text.html.... what would I pass to navigate ?

Sorry, the file name was so long I missed a character I had mistyped.
Sorry to bother you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top