how to load file from current directory into WebBrowser control?

G

Guest

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);
 
F

fitim skenderi

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
 

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