Search code examples
c#.netwpfchromiumawesomium

Can you load local content with awesomium or chromium using c#?


Using awesomium (or chromium), is it possible to load content from the file system?

Maybe by using ajax or some other method?


Solution

  • Websites in Awesomium/Chromium, just like normal websites, operate in a sandbox. This means that without the user explicitly "giving" you a file, there is no way to access it.

    However, your WPF application could easily read such a file and pass its contents to the web page using the awesomium control.

    You use CallJavascriptFunction:

    JSValue fileText = new JSValue(fileText);
    webView.CallJavascriptFunction("someMethod", fileText );
    

    Related (and where I got the base of that code from): calling Javascript from c# using awesomium

    If you want to go the other way, see Can I call application methods from JavaScript in Awesomium?