3

I'm working on a UWP app that needs to create a file outside of local storage. I use a folder picker to let the user select the output director, then I store that selection using LocalSettings and add the folder to the FutureAccessList.

Then, I use StorageFile.CreateFileAsync to create the file (which is successful, no errors or exceptions).

The problem is, the file is created with blocking, as you can see in the file properties dialog: enter image description here

Is there a specific way to create the file without this, or a way to unblock using C#?

ckruczek
  • 2,361
  • 2
  • 20
  • 23
Johnie Karr
  • 2,744
  • 2
  • 35
  • 44

1 Answers1

0

I want to share some of my finding here:

  1. Yep I can reproduce this when testing with a image. I think other files may have the same result
  2. According to the following SO thread: thread1 and thread2, the property is wrote in System.AppZoneIdentifier which is a extended property if you check it from an UWP app.(For property list you can refer to here)
  3. I test with code to get this extended property:

     IDictionary<string, object> extraProperties = await file.Properties.RetrievePropertiesAsync(propertiesName);
        var propValue = extraProperties[appzoneProperty];
        if (propValue != null)
        {
            fileProperties.AppendLine("appzone property: " + propValue);
        }
    

    I always get null value. Per my understanding this may related to permission.

  4. So finally I think if you need to modify this feature, you may have to consider using desktopbridge related technology to use FullTrustProcessLauncher. In this way, you may be able to run win32 process to modify your file's property.

Barry Wang
  • 1,459
  • 1
  • 8
  • 12
  • I saw those two threads also, but I believe the solutions don't apply to UWP. The only way to link a UWP to a Win32 app is to "side load" the UWP, which is not the direction I want to go. – Johnie Karr Dec 18 '17 at 13:19
  • @JohnieKarr FullTrustProcesslancher is desktopbridge way, which is different from "sideload". You can see this [sample](https://github.com/Microsoft/DesktopBridgeToUWP-Samples/tree/master/Samples/AppServiceBridgeSample) The difference is that you need to add capbility and fill this [form](https://developer.microsoft.com/en-us/windows/projects/campaigns/desktop-bridge). For UWP specific solution, I'm afraid we may do not have that permission to modify this attribute. – Barry Wang Dec 19 '17 at 02:19
  • thanks for the correction! I'll give this route a shot. – Johnie Karr Dec 19 '17 at 14:16
  • You want [System.ZoneIdentifier](https://learn.microsoft.com/en-us/windows/desktop/properties/props-system-zoneidentifier) not AppZoneIdentifier. 0 is unblocked, 3 is the mark of the web, see [URLZone](https://learn.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.ole.interop.urlzone?view=visualstudiosdk-2017) – Michael Hawker - MSFT Oct 02 '18 at 05:41