Home > Blockchain >  Is there a way to get folders/files cloud provider in WPF .NET 5 like in UWP?
Is there a way to get folders/files cloud provider in WPF .NET 5 like in UWP?

Time:10-01

I'm working on a task that I need to find a way to determine what is the files provider if there is any.

I've tried with UWP StorageFiles/StorageFolders.

        StorageFile storageFile = await filePicker.PickSingleFileAsync();
        var provider = storageFile.Provider;

Code: Getting StorageFile instance in UWP.

Above example returns a provider name thats gonna be 'computer' or other cloud platform name.
This does not work in WPF. I've tried with Uno.UI but it seems like half of the functionality is not implemented.

Thank you in advance! :)

CodePudding user response:

The key is to look for how to call Windows API from WPF application.

Here is a link to a blog that got me going at first.

https://www.thomasclaudiushuber.com/2019/04/26/calling-windows-10-apis-from-your-wpf-application/

And if you run an error about Windows versions, this might help:

NETSDK1135 SupportedOSPlatformVersion 10.0.19041.0 cannot be higher than TargetPlatformVersion 7.0

Edit: Later I found out that simply adding <TargetFramework>net5.0-windows10.0.17763</TargetFramework> to my projects .csproj file enabled me to use Windows.Storage namespace.

Now when I call var file = StorageFile.GetFileFromPathAsync(@"[FilePath]").GetResults(); it gets me the information I'm looking for.

  • Related