写入已从资源管理器拖放的uwp文件 [英] Write to file in uwp that has been drag-dropped from explorer
问题描述
如果从文件资源管理器中拖放文件,则它的StorageFile.Attributes
参数具有FileAttributes.ReadOnly
标志.在这种情况下,使用StorageFile
api写入文件将产生错误.在这种情况下如何写入文件?
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??
推荐答案
在这种情况下,PathIO
api可用于写入文件(除非文件是系统文件).转换数据以写入字节数组,然后添加以下代码以写入文件:
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);
这将写入这些文件而不会出现任何错误.您不需要任何其他权限,例如broadFileSystemAccess
.
This will write to these files without any error. You don't need any additional permission like broadFileSystemAccess
for this.
这篇关于写入已从资源管理器拖放的uwp文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!