Info

  • Deprecated addon Deprecated
  • Official Official addon
  • Copyright Scirra Ltd. All rights reserved.

Statistics

  • Download count835 total downloads
  • Latest download count 484 downloads of latest version
  • Average download count2 downloads per day average

Owners

The File for WebView2 plugin provides a basic ability to read and write text and binary files by file paths. It also provides a set of known folder paths, such as the path to the Documents folder, or the AppData folder for the current app. It is currently only supported in the Windows WebView2 export option.

Where possible, it's best to use the File System plugin, as it works cross-platform, including in browsers, which makes testing easier. However the File System plugin currently is only able to access files or folders after showing a picker dialog. The File for WebView2 plugin uses the new extension system in r359+ to access the file system without needing to show any prompts.

Known folder paths

This plugin provides access to a set of "known folder paths" - the path to a special system folder like the current user's Documents folder, or the AppData folder for the current app. The folder path expressions always return a path that ends in a backslash, so filenames can be appended using an expression of the form FileWebView2.AppFolder & "example.txt". The table below summarizes the available folder paths, with example folder paths using username in place of the current user's username in the folder path. Note the specific paths can change depending on the system and some may be unavailable (in which case the path is an empty string).

Expression Notes Example path
AppFolder Path to folder that contains the application executable C:\Program Files\My app\
CurrentAppDataFolder Path to AppData folder for current app and current user C:\Users\username\AppData\Local\MyAppName\
DesktopFolder C:\Users\username\Desktop\
DocumentsFolder C:\Users\username\Documents\
DownloadsFolder C:\Users\username\Downloads\
LocalAppDataFolder Path to AppData folder for current user. Note use CurrentAppDataFolder for the folder specific to the current app. C:\Users\username\AppData\Local\
PicturesFolder C:\Users\username\Pictures\
ProfileFolder Root folder for current user. C:\Users\username\
RoamingAppDataFolder Path to roaming AppData folder for current user. C:\Users\username\AppData\Roaming\
SavedGamesFolder C:\Users\username\Saved Games\
ScreenshotsFolder C:\Users\username\Screenshots\
VideosFolder C:\Users\username\Videos\
WebResourceFolder Path to subfolder that contains the application's web resource folders, typically a subfolder named www in the app folder. C:\Program Files\My app\www\

Reading and writing files

The process of reading and writing files is similar to the File System plugin, except pickers are not necessary. Reading and writing files is asynchronous, triggers are fired upon completion or an error, and tags are used to distinguish separate operations.

Note that when writing files, subfolders will be automatically created. For example if writing to the path FileWebView2.DocumentsFolder & "subfolder\anotherfolder\example.txt", then if the subfolders subfolder and anotherfolder do not exist in the Documents folder, then they will be created automatically.