Ian Vink
Ian Vink

Reputation: 68790

MonoDroid: Path to Assets to unzip a file with .NET framework

I am using the SharpZip .NET Zip Library to unzip a file found in the Assets/MyZipFolder folder.

I need to get the full path so that I can use the following:

ZipInputStream s = new ZipInputStream(File.OpenRead(_zipFile))

How do I get the path to Assets/MyZipFolder/MyZip.zip to pass to a .NET File.OpenRead command?

Upvotes: 1

Views: 1211

Answers (1)

Stuart
Stuart

Reputation: 66882

From your Context you can simply open a read stream using:

 using (var stream = Context.Assets.Open("MyZipFolder/MyZip.zip"))
 { 
      var s = new ZipInputStream(stream);
      // do read here ...
 }

Be careful that the file is marked as an AndroidAsset for build action, the absolute path is: "file:///android_asset" and remember that file names in android are case sensitive.

Upvotes: 2

Related Questions