我试图打开一个多页面的HTML网页(即test.html,test.css和test.js),它已被动态下载(因此无法使用资产)并存储在应用程序内部存储中(Xamarin.Essentials.FileSystem) .AppDataDirectory)。
我尝试使用的URL如下:
文件:///data/user/0/com.test/files/HTML/Test.html
但是我只是找不到文件。
var filesToDownload = new string[] { "http://myserver/test/test.html", "http://myserver/test/test.css" };
var directory = System.IO.Path.Combine(Xamarin.Essentials.FileSystem.AppDataDirectory, "HTML");
if (System.IO.Directory.Exists(directory))
{
System.IO.Directory.Delete(directory, true);
}
System.IO.Directory.CreateDirectory(directory);
using (var wc = new System.Net.WebClient())
{
foreach (var f in filesToDownload)
{
wc.DownloadFile(f, System.IO.Path.Combine(directory, System.IO.Path.GetFileName(f)));
}
}
var source = new UrlWebViewSource
{
Url = System.IO.Path.Combine("file://" + directory, "Test.html")
};
WebView1.Source = source;