473,394 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

how to load file from current directory into WebBrowser control?

I want to load a document which would be residing in the same directory as
the application so I pass in a string to WebBrowser control which has no path
information- normally doing this with regular File IO it knows to go to
current directory but not WebBrowser. What do I need to change? Is there some
System property which stores the path the application is running from that I
can use?

string resource = "somefile.htm";
this.webBrowser1.DocumentStream = new FileStream(resource, FileMode.Open);

Nov 3 '06 #1
1 8674
Hi,

Use ApplicationExecutablePath to get the path of where you app is residing,
then you can just append the name of the file. something like

string filename = Application.ExecutablePath + "\\" + yourfilename;

HTH

Fitim Skenderi

"MrNobody" <Mr******@discussions.microsoft.comwrote in message
news:AE**********************************@microsof t.com...
>I want to load a document which would be residing in the same directory as
the application so I pass in a string to WebBrowser control which has no
path
information- normally doing this with regular File IO it knows to go to
current directory but not WebBrowser. What do I need to change? Is there
some
System property which stores the path the application is running from that
I
can use?

string resource = "somefile.htm";
this.webBrowser1.DocumentStream = new FileStream(resource, FileMode.Open);

Nov 3 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Noozer | last post by:
When using the WebBrowser control, is it possible to cause popup windows to appear within the WebBrowser control itself instead of a new window? This is what I've written in the NewWindow2 event,...
5
by: Charles Law | last post by:
Sorry for the cross post, but I'm not sure who is best placed to answer this one. This is the most bizarre behaviour of MSHTML and streams. I have a WebBrowser control that contains nothing...
2
by: standish22 | last post by:
I want to open a word document stored in my database. What I do is save the document locally, and then open a new winform that has the WebBrowser Control on it and navigate to that new file. ...
11
by: Webbert | last post by:
I am trying to display XML in a WebBrowser Control. I receive a data feed of XML and am trying to inject it into the control. I have not been successful in doing so. The only solution I have...
6
by: titan.nyquist | last post by:
The WebBrowser control won't load a css file written in the same directory as the program. If I put an absolute path to it, it will load it. Thus, the current directory of the WebBrowser control...
1
by: Fritz Switzer | last post by:
Hello, I'm looking for a code snippet that will demonstrate how to load a stand-alone "html" file in a WebBrowser control (the one that ships with VS 2005) that I am using as part of a WinForms...
2
by: Scott Gravenhorst | last post by:
I recently (within 30 days) downloaded and installed VB 2005 Express. I like it a whole lot... but: I have been trying to work with the WebBrowser control to display a small amount of help text...
4
by: David | last post by:
I'm using the AxSHDocVw.WebBrowser control to download data from a webpage at work (it's an internal page on my company's intranet). The page produces a runtime error after a while and the...
3
by: Rebeccardr | last post by:
I have a problem where I am using the following code to open an external avi file. I am outputting the code to external html file for debugging purposes and after I have set my security settings...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.