0
votes

I am trying to read a zip file remotly from a url this bit works fine if its from disk but I want to read it remotly without unzipping the file first is that possible or would it make the file inacessable to others?.

public void GetMSFSAddonDetails(string zipFileUrl) {
    using (ZipArchive archive = ZipFile.OpenRead(zipFileUrl))
    {
       var sample = archive.GetEntry("manifest.json");
       if (sample != null)
       {
          using (var zipEntryStream = sample.Open())
       {
           // serializer = new XmlSerializer(typeof(SampleClass));

          /// SampleClass deserialized =
            //  (SampleClass)serializer.Deserialize(zipEntryStream);
      
       }
      
}

Edit 2 I am getting the following error when i try to donwload a zip file from the url

This is using android forms with the mainfest

<?xml version="1.0" encoding="utf-8"?>
  <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
  android:versionCode="1" android:versionName="1.0" 
  package="com.companyname.msfsaddonshub.forms" android:installLocation="auto">
 <uses-sdk android:minSdkVersion="28" android:targetSdkVersion="29" />
 <application android:label="MSFSAddonsHub.Forms.Android" android:theme="@style/MainTheme"></application>
 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>

01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] at System.IO.Compression.ZipFile.Open (System.String archiveFileName, System.IO.Compression.ZipArchiveMode mode) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.IO.Compression.ZipFile/src/System/IO/Compression/ZipFile.cs:81 01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] at System.IO.Compression.ZipFile.OpenRead (System.String archiveFileName) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.IO.Compression.ZipFile/src/System/IO/Compression/ZipFile.cs:39 01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] at MSFSAddonsHub.BL.MSFSBL.GetMSFSAddonDetails (System.String zipFileUrl) [0x00001] in D:\GitMaster\MSFSAddonsHub\MSFSAddonsHub.BL\MSFSAddonsHub.BL\MSFSBL.cs:17 01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] at MSFSAddonsHub.BL.MSFSBL.DownloadTestFile () [0x00001] in D:\GitMaster\MSFSAddonsHub\MSFSAddonsHub.BL\MSFSAddonsHub.BL\MSFSBL.cs:13 01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] at MSFSAddonsHub.Forms.Views.MainMenu..ctor () [0x0001a] in D:\GitMaster\MSFSAddonsHub\MSFSAddonsHub.Forms\MSFSAddonsHub.Forms\MSFSAddonsHub.Forms\Views\MainMenu.xaml.cs:20 01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] at (wrapper managed-to-native) System.Reflection.RuntimeConstructorInfo.InternalInvoke(System.Reflection.RuntimeConstructorInfo,object,object[],System.Exception&) 01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] at System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x00005] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:936 01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] --- End of inner exception stack trace --- 01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] at System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x00018] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:944 01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] at System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic, System.Boolean wrapExceptions) [0x00095] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/ReferenceSources/RuntimeType.cs:185 01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] at System.RuntimeType.CreateInstanceSlow (System.Boolean publicOnly, System.Boolean wrapExceptions, System.Boolean skipCheckThis, System.Boolean fillCache) [0x00009] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/ReferenceSources/RuntimeType.cs:155 01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] at System.RuntimeType.CreateInstanceDefaultCtor (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Boolean wrapExceptions, System.Threading.StackCrawlMark& stackMark) [0x00027] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/rttype.cs:5770 01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] at System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic, System.Boolean wrapExceptions) [0x00039] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/activator.cs:206 01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] at System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/activator.cs:190 01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] a

1
What do you mean by "without unzipping the file first"? Also, as per your code it seems like you're already attempting to read the stream of the file you're interested in, so what is your actual problem? - silkfire

1 Answers

0
votes

As far as I know the method ZipFile.OpenRead(String) does not handle URLs! It expects an archiveFileName and searches on the disk.

You would probably have to download the zip file and open it afterwards.