ERLEDIGT
JA
JA
ANTWORTEN
3
3
ZUGRIFFE
452
452
EMPFEHLEN
-
Hallo,
Ich habe versucht den code aus dem beitrag
Zu adaptieren und um eine Pfadeingabe mittesl Save file Dialog erweitert doch irgenetwas mache ich Falsch da ich immer nur Lere Zip files erstelle ohne inhalt obwol im Ordner eindeutig inhalt verhanden ist
Mfg
Lusiphur
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
string parentPath; private void button1_Click(object sender, EventArgs e) { saveFileDialog1.Filter = "Backup Dateien | *.zip"; saveFileDialog1.DefaultExt = "*.zip"; saveFileDialog1.ShowDialog(); string path3=saveFileDialog1.FileName.ToString(); ZipOutputStream s = new ZipOutputStream(File.Create(path3)); s.SetLevel(1); DirectoryInfo maindir = new DirectoryInfo("C:\\Projekt\\"); parentPath = maindir.Parent.FullName + @"\"; MessageBox.Show(parentPath); GoSubdirs(ref s, statics.Projektpfad); s.Close(); } private void GoSubdirs(ref ZipOutputStream s, string path) { DirectoryInfo dir = new DirectoryInfo(path); foreach (DirectoryInfo subdir in dir.GetDirectories()) { GoSubdirs(ref s, subdir.FullName); } foreach (FileInfo fi in dir.GetFiles()) { FileStream fs = File.OpenRead(fi.FullName); byte[] buffer = new byte[fs.Length]; fs.Read(buffer, 0, buffer.Length); ZipEntry entry = new ZipEntry(dir.FullName.Replace(parentPath, "") + "/" + fi.Name); entry.Size = fs.Length; fs.Close(); s.PutNextEntry(entry); s.Write(buffer, 0, buffer.Length); } }
-
25.05.07 13:20 #2
- Registriert seit
- Aug 2001
- Ort
- Österreich, Stmk, Graz
- Beiträge
- 2.783
Hallo.
Was mir auf die Schnelle aufgefallen ist:
Code csharp:1 2 3
DirectoryInfo maindir = new DirectoryInfo("C:\\Projekt\\"); parentPath = maindir.Parent.FullName + @"\"; MessageBox.Show(parentPath);
Du bastelst dir da einen Pfad zusammen.. und zeigst ihn dir via MessageBox an.
Code csharp:1
GoSubdirs(ref s, statics.Projektpfad);
Benutzt dann aber doch was anderes. Stimmt der Pfad?
Im übrigen hat AsterixAoH eine kleine Ausbesserung am Code gemacht, die du auch übernehmen solltest.
lg, AlexWith the first link the chain is forged. The first speech censored, the first thought forbidden, the first freedom denied, chains us all irrevocably.
Aaron Satie
Legends... are the spice of the universe, Mr. Data, because they have a way of sometimes coming true.
Captain Jean-Luc Picard, Stardate ~41294.5
Tutorials.de chattet. Hier gibts auch .net Support ^^
Klickt auf chattet und nutzt den Webchat, oder verbindet euch zu irc.tutorials.de - Channel #Tutorials.de
(moo)blog furred.net // SiteInfo für WP7 // Pastebin für WP7 // BlogEngine.net Extensions
-
das Problem ist nun das ich zwar ein Zipfile der Richtigen größe erhalte 68 K aber es ist ohne Daten ?
was ist da nun Los
Die Änderungen die Sie anmerkten beziehen sich nur auf das Entpacken diese abe ich noch nichteinmal bearbeitet
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
public string parentPath; private void button1_Click(object sender, EventArgs e) { ZipOutputStream s = new ZipOutputStream(File.Create(@"C:\testzip.zip")); s.SetLevel(1); DirectoryInfo maindir = new DirectoryInfo("C:\\Projekt"); parentPath = maindir.Parent.FullName + @"\"; MessageBox.Show(parentPath); GoSubdirs(ref s,"C:\\Projekt"); s.Close(); } private void GoSubdirs(ref ZipOutputStream s, string path) { DirectoryInfo dir = new DirectoryInfo(path); foreach (DirectoryInfo subdir in dir.GetDirectories()) { GoSubdirs(ref s, subdir.FullName); } foreach (FileInfo fi in dir.GetFiles()) { FileStream fs = File.OpenRead(fi.FullName); byte[] buffer = new byte[fs.Length]; fs.Read(buffer, 0, buffer.Length); ZipEntry entry = new ZipEntry(dir.FullName.Replace(parentPath,"") + "/" + fi.Name); entry.Size = fs.Length; fs.Close(); s.PutNextEntry(entry); s.Write(buffer, 0, buffer.Length); s.Flush(); }
-
Das Problem lag mit win Vista zusammen mit XP funktioniert es
Ähnliche Themen
-
Mit Ionic zippen
Von Perserhood im Forum .NET CaféAntworten: 4Letzter Beitrag: 31.03.10, 12:40 -
zippen mit struktur?!
Von chrisdu im Forum .NET ArchivAntworten: 15Letzter Beitrag: 09.02.09, 17:56 -
Ordner zippen
Von Saskia21 im Forum JavaAntworten: 1Letzter Beitrag: 29.02.08, 16:34 -
Ist Zippen mit java.util.zip wie zippen mit Zipprogrammen
Von Java? im Forum JavaAntworten: 1Letzter Beitrag: 01.02.08, 11:38 -
Dateien zippen
Von Yamah im Forum PHPAntworten: 2Letzter Beitrag: 15.09.04, 11:22





Zitieren

Login





