简体   繁体   中英

CreateFileAsync creates blocked file

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: 在此处输入图片说明

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM