Is it possible to set a WebBrowser.DocumentText file to a file without reading the file, setting its contents to a string variable, and then setting WebBrowser.DocumentText to this string variable? I would not mind writing code so much, it just looks like it should be possible without it.
Do you mean "do not read the file yourself"? Although these examples include "reading the file yourself," they are pretty simple:
browser.DocumentStream = new FileStream("file.html", FileMode.Open, FileAccess.Read);
or
browser.DocumentText = File.ReadAllText("file.html")
You can read the file in a line and set the property.
Note that MSDN says this:
, WebBrowser : URL- . , Navigating, Navigated DocumentCompleted , , Url .
, FileStream, , , DocumentStream.
FileStream
DocumentStream
As others have said, you can read the stream and set it to the DocumentStream property .
An alternative is to set the Url property using the url file:
webBrowser.Url = new Url(@"file://C:\file.html");
Use the method Navigate.
Navigate
WebBrowser wb = new WebBrowse(); //Put it on a form wb.Navigate(filePath);
The file path should look like file://server/filename.extor file://C:/path/filename.ext.
file://server/filename.ext
file://C:/path/filename.ext
Source: https://habr.com/ru/post/1791309/More articles:In an add-in for Outlook 2010, how can I delete a delete operation? - c #https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1791305/internet-explorer-tries-to-run-jquery-before-loading-the-library&usg=ALkJrhghOz_3xsWx74QJHFh7-VXRYjqrGgQuestion Matlab - analysis of the main components - matlabDirectDraw surface memory access directly in C # - c #Comparing two RTF documents side by side in Word (VSTO) - c #MariaDB on Windows - what is this error when trying to start the database engine? - mariadbWhat size images should be used to support two iphone resolutions? - iphoneMariaDB on Windows - help with startup? - databaseActiveRecord, MySQL and nested transactions - what is the behavior? - mysqlAn attempt to develop PostFix notation in a tree using Perl - perlAll Articles