how to load file from current directory into WebBrowser control?

  • Thread starter Thread starter Guest
  • Start date Start date
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);
 
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
 
Back
Top