Write to file in uwp that has been drag-dropped from explorer

旧街凉风 提交于 2020-07-09 05:55:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!