1

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?

Ian Vink
  • 66,960
  • 104
  • 341
  • 555
  • 1
    Assets don't have a physical representation in the filesystem so there is no path. But it should work like in standard Android too: http://stackoverflow.com/questions/9544737/read-file-from-assets – zapl May 13 '12 at 01:13

1 Answers1

2

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.

SushiHangover
  • 73,120
  • 10
  • 106
  • 165
Stuart
  • 66,722
  • 7
  • 114
  • 165