Web view UWP not loading files in the machine - webview

can I open a html file on the C drive or on any location using the web view in UWP?
I am using the following code but it is not working:
Uri targeturi = new Uri("C:/Users/user/Pictures/Files/Forms/dac36cac-5d83-4fae-bf4f-112361b719ea/index.html");
browser.Navigate(targeturi);

In uwp files have limited access permission. By the default the app can only access the application install directory and data locations. Additional locations require special capabilities. More details about file access permission please reference this document.
You can gain access to files and folders on a removable device by calling the file picker (using FileOpenPicker and FolderPicker) and letting the user pick files and folders for your app to access. Learn how to use the file picker in Open files and folders with a picker.
According to your code snippet, you want to access the HTML file inside the picture folder. For accessing file in picture folder please reference Files and folders in the Music, Pictures, and Videos libraries. Pay attention on the Capabilities page, select the libraries that your app manages. So the correct way to open the file and show it in the WebView may as follows:
StorageFolder storageFolder = await KnownFolders.GetFolderForUserAsync(null /* current user */, KnownFolderId.PicturesLibrary);
StorageFile indexFile = await storageFolder.GetFileAsync("index.html");/*Change to your file path inside the picture folder*/
browser.NavigateToString(await FileIO.ReadTextAsync(indexFile));
You may find I used the NavigateToString method. The Navigate(Uri) method can not navigate to a file by path directly. To load uncompressed and unencrypted content from your app’s LocalFolder or TemporaryFolder data stores, use the Navigate method with a Uri that uses the `ms-appdata scheme, to HTML content in the app package using the ms-appx-web scheme. For example:
webView1.Navigate("ms-appx-web:///help/about.html");
More details please reference "Navigating to content" of WebView. And the scenario 5 of the official sample provide samples about navigating to file you can reference.

Related

Hyperlink to a file in the current folder regardless of its location on the drive

Putting together a .doc file with a table of content with links to external files. The challenge is: how to make them so that it points to the given file in the current folder regardless of its location on the disk.
Context: I will be sending the set of files to another person, so I can't put the path on my machine, nor on a server since they will be working offline. They will be working on Remarkable device and I want them to be able to use the major overview file with the links to access each of the files, rather than having to browse the folders.

Can images from a user's photos library moved to the Hidden folder from a third party application?

Photos Framework provides an API to move to folders. But, is there a way to change the status of an image to hidden, and thereby move it to the iOS Hidden folder and hiding it from the main photo gallery?
If you want to save some data privately so no other app could access it you probably need to save it into the app data container. This could be a /Documents folder for example. Take a look at FileManager class to work with file system.
Use this directory to store user-generated content. The contents of this directory can be made available to the user through file sharing; therefore, his directory should only contain files that you may wish to expose to the user.
The contents of this directory are backed up by iTunes and iCloud.
File system documentation

How do i display files from a users OneDrive using the Microsoft Graph Api

I'm currently working with the OneDrive API to get files from a users OneDrive.
I need to be able to display a file from OneDrive dynamically, depending on what element a user clicks on.
I Know that I can go into my OneDrive and get a Embedded Link that I can use to display a file from my OneDrive, but this is not what I need. I attempted to use the Embedded Link combined with data binding but the link requires a authorization token unique the initial embedded link.
Essentially I want a user to click on a element corresponding to a OneDrive element (eg a file or pdf). Then have file will display in a IFrame on the page.
For Office documents, you can use the webUrl property from a DiveItem. This URL will open the document in the editor associated with that file type. For example, navigating to the webUrl for a .ppt file will open that document in PowerPoint Online.
For other files, the webUrl property simply points to the file itself. What happens when you navigate to that address will depend on the file type and what applications you have installed. Navigating to a .pdf generally will show that file in the browser (most browsers support PDF) but other files may not have an application and therefore just download to the local machine.
You can open the URLs into an iframe but be careful to ensure you're UI is taking up minimal screen area. Also make sure you're page is responsive so users can use the app in a smaller window and/or mobile device without your UI eating up so much canvas that they can't see/use the document itself.
here is an example of a creation of an edit link in onedrive, you can change the type of edit to embeed to get what you want, this is in php utilizing laravel, the graph api with the docs https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/item_createlink
public function getEditableEmbeed($itemid){
$this->refresh();
$file = $this->getGraph()->createRequest("POST", "/me/drive/items/".$itemid."/createLink")->attachBody('{ "type": "edit", "scope": "anonymous"}')->execute();
return $file;
}

iOS file browser example

Does anyone have some sample code demonstrating how to make a "file browser" view? I'd like to be able to navigate through directories and drill-down the sub-directories and see files located within the various folders. I want the user to be able to create new directories/files and even select an existing file. Is there sample code out there already available to do this?
I don't know about sample code, but this wouldn't be too complicated to achieve using NSFileManager and a UITableView.
You can obtain arrays of directory contents using the subpathsOfDirectoryAtPath:error and associated methods of a file manager. These arrays in turn can populate a UITableView. It would be fairly easy to put together a navigation controller that could display a series of table views showing a file hiearchy.
Bear in mind, however, that you'll only be able to access the directories inside your application sandbox, unless you're running on a jailbroken device.
The iOS programming guide says that
You should never present users with the list of files in this directory and ask them to decide what to do with those files. Instead, sort through the files programmatically and add files without prompting.
This is assuming you are trying to implement file browse feature for your documents directory.
I'm an author of FileExplorer which is a file browser for iOS and fulfills most of your requirements.
Here are some of the features of my control:
Possibility to choose files or/and directories if there is a need for that
Possiblity to remove files or/and directories if there is a need for that
Built-in search functionality
View Audio, Video, Image and PDF files.
Possibility to add support for any file type.
You can find my control here.

How to list my application when you try to open a PDF in email?

I wanted to list my application in the list of other readers installed in the iphone when I try to open the PDF from the email. What settings do I need to do on my project so that my application is also listed in it.
Are you looking for Implementing Support for Custom File Formats?
Applications that are able to
open specific document or file formats
may register those formats with the
system. When the system or another
application needs to open a file, it
can hand that file off to your
application to do so. In order to
support custom file formats, your
application must:
Register the file types your
application supports with the system.
Implement the proper methods to open
files (when asked to do so by the
system).

Resources