Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

383
Views
C# ¿Cómo puedo extraer fotos de un archivo zip de manera más rápida y eficiente sin extraerlas usando ZipArchive?

Tengo una aplicación de xamarin que lee fotos sin extraerlas en un archivo zip.

Cuando hago clic muy rápido en la página donde se deben mostrar las fotos. A veces, la mitad no se muestra porque la aplicación aún no ha podido leerlos todos.

Navegar después de esa página es así

 public async void Handle_ItemTapped(object sender, ItemTappedEventArgs e) { Content tappedStep = (Content)MyListView.SelectedItem; int stepIndex = tappedStep.contentid; string nextTitle = _protocol.name; using (UserDialogs.Instance.Loading("Loading", null, null, true, MaskType.Black)) { loading = true; if (loading) { Title = nextTitle; } await Navigation.PushAsync(new StepView(_protocol, Title, tappedStep.chaptertitle, stepIndex)); } ((ListView)sender).SelectedItem = null; }

Entonces, si quiero navegar demasiado rápido después de la vista escalonada, las fotos a menudo no están todas allí.

Este es el código que uso para leer las fotos en el archivo zip.

 private string PathToZip() { string folderName = $"protocol-{_protocol.id}-{_protocol.versionnr}.zip"; string extractPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); string zipPath = $"{$"{extractPath}"}/{$"{folderName}"}"; return zipPath; } private async Task GetImage() { try { PathToZip(); int currentIndex = GetCurrentIndex(); Content content = _protocol.contents[currentIndex]; string imageName = $"{content.contentid}.jpg"; using (ZipArchive archive = ZipFile.OpenRead(PathToZip())) { for (int i = 0; i < archive.Entries.Count; i++) { ZipArchiveEntry pictureEntry = archive.Entries[i]; if (pictureEntry.Name == imageName) { //for reading the image byte[] buffer; long length = pictureEntry.Length; buffer = new byte[length]; pictureEntry.Open().Read(buffer, 0, (int)length); myImage.Source = ImageSource.FromStream(() => new MemoryStream(buffer)); } } } } catch (Exception) { } }

¿Cómo puedo hacer que esto sea más eficiente para que, si la aplicación aún no ha cargado todo, cuando quiera navegar a la página siguiente, la aplicación espere a que se lea cada página?

Gracias por adelantado

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!