During the first start of my app, I would like to give the user the ability to grant access to certain sync apps like Dropbox.
Is there any way my UWP App can detect that Dropbox is installed? I could then prompt the user to provide access to that folder via FolderPicker....
Determining whether Dropbox is installed isn't possible from a UWP app. Or, at least, is probably not the recommended method of access to Dropbox from a UWP app.
On Windows the user's Dropbox folder location is stored in %localappdata%\Dropbox\info.json
so in WPF/WinForms/Console applications you can use something like:-
using Newtonsoft.Json.Linq;
using System;
using System.IO;
public static class Dropbox
{
private static string _Path;
public static string Path
{
get { return _Path ?? (_Path = GetPath()); }
}
static string GetPath()
{
var appDataPath = Environment.GetFolderPath(
Environment.SpecialFolder.LocalApplicationData);
var filePath = System.IO.Path.Combine(appDataPath, @"Dropbox\info.json");
dynamic dropboxInfo = JObject.Parse(File.ReadAllText(filePath));
string folderPath = dropboxInfo.personal.path;
return folderPath;
}
}
Due to lack of access to %localappdata%
this method falls at the first hurdle in a UWP app.
This leaves you either prompting the user for the Dropbox folder location without knowing whether it's installed or using the Dropbox SDK to connect to Dropbox and access files independently of any copy the user already has locally via the Dropbox client.