问题
If file is dragged and dropped from file explorer it has FileAttributes.ReadOnly
flag for StorageFile.Attributes
parameter. In that case using StorageFile
api to write to file will give error. How to write to file in this case??
回答1:
In this case PathIO
api can be used to write to file (unless file is a system file). Convert data to write into bytes array and then add following code to write to file:
await PathIO.WriteBytesAsync(file.Path, bytes);
This will write to these files without any error. You don't need any additional permission like broadFileSystemAccess
for this.
来源:https://stackoverflow.com/questions/62638922/write-to-file-in-uwp-that-has-been-drag-dropped-from-explorer