I'm new here and currently programming a Windows 10 Desktop UWP for my company, which should check a txt-file by a background task and update the UWP tile / UWP secondary tile.
Checking the users libraries by using the StorageLibraryContentChangedTrigger is simple and works fine. But my company says, that the users libraries is a not an good idea to save a txt-file (sample 1):
StorageLibrary videosLib = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Videos);
StorageLibraryContentChangedTrigger videoTrigger = StorageLibraryContentChangedTrigger.Create(videosLib);
taskBuilder = new BackgroundTaskBuilder();
taskBuilder.Name = taskNameFileChanged;
taskBuilder.TaskEntryPoint = taskFileChangedEntryPoint;
taskBuilder.SetTrigger(videoTrigger);
register = taskBuilder.Register();
Checking the app local folder by using this code (sample 2):
List<string> typeFilter = new List<string>();
typeFilter.Add(".txt");
var queryoptions = new Windows.Storage.Search.QueryOptions(Windows.Storage.Search.CommonFileQuery.OrderByName, typeFilter);
var query = ApplicationData.Current.LocalFolder.CreateFileQueryWithOptions(options);
//subscribe on query's ContentsChanged event
query.ContentsChanged += Query_ContentsChanged;
private void Query_ContentsChanged(Windows.Storage.Search.IStorageQueryResultBase sender, object args)
{
Debug.WriteLine("File has changed!!!!");
}
is also working, but only if the UWP is opened / active.
Q1: Is there a way, that triggers the ApplicationData.Current.LocalFolder, so i can say e.g. "ApplicationData.Current.LocalFolder.ContentChangedTrigger"?
Q2: If Q1 is not possible, how can i else check the ApplicationData.Current.LocalFolder for content changes by a background task?
Q3: I know that an UWP runs in a Sandbox, but can an UWP have a restricted access to a windows registry key? Read access would already suffice.
Thanks in advance for the answers :-)