Ryan Marks
Ryan Marks

Reputation: 118

Is there anyway that allows me to use System.IO in a UWP application

I'm currently working on a UWP application and one of the things I need to do is write bytes to files using the System.IO class. This is because one of the libraries my application depends on uses the System.IO.File.WriteAllBytes() method.

Using the StorageFolder class isn't quite something that I'm looking to do since a couple of the projects I am making (some are not UWP, some are CLIs) depend on this library I have written and the StorageFolder is only available in UWP.

I've added broadFileSystemAccess as one of the capabilities of my UWP application. However, after reading the documentation carefully I found out that this capability only affects the StorageFolder class and not the System.IO class. In addition, I'm the only person who will be using this application, so I thought that enabling the file access rights in the System Settings (as shown in the image provided) would help. However that did not help at all

enter image description here

Here is the exception message that I am getting

"Access to the path 'C:\\proj\\proj_tig\\Project 112\\bin\\x64\\Debug\\AppX\\Dependencies.zip' is denied."

Is there any possible way to use the System.IO.File.WriteAllBytes() method at all in UWP?

Upvotes: 1

Views: 232

Answers (1)

Nico Zhu
Nico Zhu

Reputation: 32775

Is there anyway that allows me to use System.IO in a UWP application

For checking the path, and it looks a apps installation folder, unfortunately, the installation folder is read-only, we can't write data into. we suggest you use app' local folder that with full permission, and you could use System.IO namespace to access. For more detail please refer this document.

Upvotes: 1

Related Questions