469,282 Members | 2,257 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

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

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.

Sep 20 '07 #1
5 22971
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]
- mv*@spam.guard.caspershouse.com

<ti*****@gmail.comwrote in message
news:11**********************@19g2000hsx.googlegro ups.com...
>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.

Sep 20 '07 #2
On Sep 20, 9:56 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
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]
- m...@spam.guard.caspershouse.com

<timn...@gmail.comwrote in message

news:11**********************@19g2000hsx.googlegro ups.com...
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 ?

Sep 20 '07 #3
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]
- mv*@spam.guard.caspershouse.com

<ti*****@gmail.comwrote in message
news:11**********************@r29g2000hsg.googlegr oups.com...
On Sep 20, 9:56 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
> 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]
- m...@spam.guard.caspershouse.com

<timn...@gmail.comwrote in message

news:11**********************@19g2000hsx.googlegr oups.com...
>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 ?

Sep 20 '07 #4
Hi.
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 ?
Try it with IE, maybe you should use file://c:\......
Sep 20 '07 #5
On Sep 20, 10:21 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
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]
- m...@spam.guard.caspershouse.com

<timn...@gmail.comwrote in message

news:11**********************@r29g2000hsg.googlegr oups.com...
On Sep 20, 9:56 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
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]
- m...@spam.guard.caspershouse.com
<timn...@gmail.comwrote in message
>news:11**********************@19g2000hsx.googlegr oups.com...
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.

Sep 20 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

20 posts views Thread by Steve | last post: by
3 posts views Thread by Christopher D. Wiederspan | last post: by
reply views Thread by Khalilskp | last post: by
1 post views Thread by PJSimon | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.