I am developing a application in Xamarin for Mac. I have a html page whose build action is set to BundledResource
s and it is in root folder. My problem is that when I want to show it in WebView Control, It Does not open it. When I tries to open it using FileStream
it throws UnAuthorizedAccessException
. The exception does not comes in debug mode but when I build package through Xamarin and install it on a another machine where Xamarin Studio is not installed it throws the exception. the code is as below.
public void LoadHTMLPage()
{
try
{
string filepath= NSBundle.MainBundle.PathForResource("HTMLPage", "html");
NSUrl url = new NSUrl(filepath, false);
string localHtmlUrl = filepath;
if (File.Exists(localHtmlUrl))
{
MsgBox.Show("File Exist","");
webBrowser.MainFrame.LoadRequest(new NSUrlRequest(url));
}
}
catch (Exception ex)
{
}
}
Although MsgBox is displayed which shows that html file exists on the path.