Webview在通用的Windows应用程序

我在我的通用Windows 10应用程序中使用webview控件来打开任何链接,如:Uri uri = new(“ http://www.c-sharpcorner.com ”); WebView1.Navigate(URI); 现在我想在webview中打开MS Excel文件。 我将我的excel文件保存为.htm / .html格式,然后我想在webview中打开这个.htm / .html页面,但是当我尝试在浏览器(Firefox / explorer)中打开它时, 。 我复制相同的链接并通过WebView1.Navigate(//链接//); 但不开放。 如何在webview中打开这个.htm / .html(excel文件)。

谢谢。

首先在你的应用程序设置中创build一个文件夹,然后在该文件夹中创build你的html文件,最后给你打电话给你的webview

string desiredfName = "test.html"; StorageFolder newFolder = await localFolder.CreateFolderAsync(desiredName, CreationCollisionOption.ReplaceExisting); StorageFile file = await newFolder.CreateFileAsync(desiredfName,CreationCollisionOption.ReplaceExisting); await FileIO.WriteTextAsync(file, ht); string url = "ms-appdata:///local/news/test.html"; mywebview.Navigate(new Uri(url));