public void FindEntriesInArchiveWithLongComment() { string tempFile = GetTempFilePath(); Assert.IsNotNull(tempFile, "No permission to execute this test?"); tempFile = Path.Combine(tempFile, "SharpZipTest.Zip"); string longComment = new String('A', 65535); MakeZipFile(tempFile, "", 1, 1, longComment); using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { try { using (IsolatedZipFile zipFile = new IsolatedZipFile(tempFile)) { foreach (ZipEntry e in zipFile) { Stream instream = zipFile.GetInputStream(e); CheckKnownEntry(instream, 1); } zipFile.Close(); } } finally { store.DeleteFile(tempFile); } } }
public void RoundTrip() { string tempFile = GetTempFilePath(); Assert.IsNotNull(tempFile, "No permission to execute this test?"); tempFile = Path.Combine(tempFile, "SharpZipTest.Zip"); using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { try { MakeZipFile(tempFile, "", 10, 1024, ""); using (IsolatedZipFile zipFile = new IsolatedZipFile(tempFile)) { foreach (ZipEntry e in zipFile) { Stream instream = zipFile.GetInputStream(e); CheckKnownEntry(instream, 1024); } zipFile.Close(); } } finally { store.DeleteFile(tempFile); } } }
/// <summary> /// </summary> private void ZipFileFromISO(object sender, RoutedEventArgs e) { DeleteSampleText(); /* * Extract an archive using IsolatedZipFile ************************************************************* */ using (var zip = new IsolatedZipFile(SampleZipFileName)) { var entry = zip.GetEntry(SampleTextFileName); using (var streamIn = zip.GetInputStream(entry)) { using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { using (var streamOut = store.OpenFile(SampleTextFileName, FileMode.Create)) { streamIn.CopyTo(streamOut); } } } } /************************************************************* * */ DisplayMetrics("ZipFileFromISO", false); }
public void Noid() { using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedStorageFileStream fs = store.CreateFile("foo.txt")) { using (var writer = new StreamWriter(fs)) { writer.Write("Foo Bar FU!"); } } store.CreateDirectory("foobarfu"); string fooText = Guid.NewGuid().ToString(); using (var createdFile = store.CreateFile("foo.txt")) { using (var writer = new StreamWriter(createdFile)) { writer.Write(fooText); } } using (var createdFile = store.CreateFile("foobarfu\\foo.txt")) { using (var writer = new StreamWriter(createdFile)) { writer.Write(fooText); } } var factory = new IsolatedZipEntryFactory(); ZipEntry fentry = factory.MakeFileEntry("foo.txt"); ZipEntry dentry = factory.MakeDirectoryEntry("foobarfu"); using (var f = IsolatedZipFile.Create("foo.zip")) { f.BeginUpdate(); f.Add("foo.txt"); f.CommitUpdate(); } using (var f = new IsolatedZipFile("foo.zip")) { var entry = f.GetEntry("foo.txt"); string content = new StreamReader(f.GetInputStream(entry)).ReadToEnd(); Assert.AreEqual(fooText, content); } var fz = new IsolatedFastZip(); fz.CreateZip("fz.zip", "foobarfu", true, ""); } }
public void Noid() { using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedStorageFileStream fs = store.CreateFile("foo.txt")) { using (var writer = new StreamWriter(fs)) { writer.Write("Foo Bar FU!"); } } store.CreateDirectory("foobarfu"); string fooText = Guid.NewGuid().ToString(); using (var createdFile = store.CreateFile("foo.txt")) { using (var writer = new StreamWriter(createdFile)) { writer.Write(fooText); } } using (var createdFile = store.CreateFile("foobarfu\\foo.txt")) { using (var writer = new StreamWriter(createdFile)) { writer.Write(fooText); } } var factory = new IsolatedZipEntryFactory(); ZipEntry fentry = factory.MakeFileEntry("foo.txt"); ZipEntry dentry = factory.MakeDirectoryEntry("foobarfu"); using (var f = IsolatedZipFile.Create("foo.zip")) { f.BeginUpdate(); f.Add("foo.txt"); f.CommitUpdate(); } using (var f = new IsolatedZipFile("foo.zip")) { var entry = f.GetEntry("foo.txt"); string content = new StreamReader(f.GetInputStream(entry)).ReadToEnd(); Assert.AreEqual(fooText, content); } var fz = new IsolatedFastZip(); fz.CreateZip("fz.zip", "foobarfu", true, ""); } }
public void PartialStreamClosing() { string tempFile = GetTempFilePath(); if (tempFile != null) { tempFile = Path.Combine(tempFile, "SharpZipTest.Zip"); MakeZipFile(tempFile, new String[] { "Farriera", "Champagne", "Urban myth" }, 10, "Aha"); using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedZipFile zipFile = new IsolatedZipFile(tempFile)) { Stream stream = zipFile.GetInputStream(0); stream.Close(); stream = zipFile.GetInputStream(1); zipFile.Close(); } store.DeleteFile(tempFile); } } }
public void PartialStreamClosing() { string tempFile = GetTempFilePath(); if (tempFile != null) { tempFile = Path.Combine(tempFile, "SharpZipTest.Zip"); MakeZipFile(tempFile, new String[] { "Farriera", "Champagne", "Urban myth" }, 10, "Aha"); using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedZipFile zipFile = new IsolatedZipFile(tempFile)) { Stream stream = zipFile.GetInputStream(0); stream.Close(); stream = zipFile.GetInputStream(1); zipFile.Close(); } store.DeleteFile(tempFile); } } }
public void BasicEncryptionToDisk() { const string TestValue = "0001000"; string tempFile = GetTempFilePath(); Assert.IsNotNull(tempFile, "No permission to execute this test?"); tempFile = Path.Combine(tempFile, "SharpZipTest.Zip"); using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedZipFile f = IsolatedZipFile.Create(tempFile)) { f.Password = "******"; StringMemoryDataSource m = new StringMemoryDataSource(TestValue); f.BeginUpdate(); f.Add(m, "a.dat"); f.CommitUpdate(); } using (IsolatedZipFile f = new IsolatedZipFile(tempFile)) { f.Password = "******"; // TODO: Testing is not yet ported - Assert.IsTrue(f.TestArchive(true), "Archive test should pass"); } using (IsolatedZipFile g = new IsolatedZipFile(tempFile)) { g.Password = "******"; ZipEntry ze = g[0]; Assert.IsTrue(ze.IsCrypted, "Entry should be encrypted"); using (StreamReader r = new StreamReader(g.GetInputStream(0))) { string data = r.ReadToEnd(); Assert.AreEqual(TestValue, data); } } store.DeleteFile(tempFile); } }
public void FindEntriesInArchiveExtraData() { string tempFile = GetTempFilePath(); Assert.IsNotNull(tempFile, "No permission to execute this test?"); bool fails; using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { tempFile = Path.Combine(tempFile, "SharpZipTest.Zip"); string longComment = new String('A', 65535); FileStream tempStream = store.CreateFile(tempFile); MakeZipFile(tempStream, false, "", 1, 1, longComment); tempStream.WriteByte(85); tempStream.Close(); fails = false; try { using (IsolatedZipFile zipFile = new IsolatedZipFile(tempFile)) { foreach (ZipEntry e in zipFile) { Stream instream = zipFile.GetInputStream(e); CheckKnownEntry(instream, 1); } zipFile.Close(); } } catch { fails = true; } store.DeleteFile(tempFile); } Assert.IsTrue(fails, "Currently zip file wont be found"); }
public void FindEntriesInArchiveExtraData() { string tempFile = GetTempFilePath(); Assert.IsNotNull(tempFile, "No permission to execute this test?"); bool fails; using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { tempFile = Path.Combine(tempFile, "SharpZipTest.Zip"); string longComment = new String('A', 65535); FileStream tempStream = store.CreateFile(tempFile); MakeZipFile(tempStream, false, "", 1, 1, longComment); tempStream.WriteByte(85); tempStream.Close(); fails = false; try { using (IsolatedZipFile zipFile = new IsolatedZipFile(tempFile)) { foreach (ZipEntry e in zipFile) { Stream instream = zipFile.GetInputStream(e); CheckKnownEntry(instream, 1); } zipFile.Close(); } } catch { fails = true; } store.DeleteFile(tempFile); } Assert.IsTrue(fails, "Currently zip file wont be found"); }
public void FindEntriesInArchiveWithLongComment() { string tempFile = GetTempFilePath(); Assert.IsNotNull(tempFile, "No permission to execute this test?"); tempFile = Path.Combine(tempFile, "SharpZipTest.Zip"); string longComment = new String('A', 65535); MakeZipFile(tempFile, "", 1, 1, longComment); using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { try { using (IsolatedZipFile zipFile = new IsolatedZipFile(tempFile)) { foreach (ZipEntry e in zipFile) { Stream instream = zipFile.GetInputStream(e); CheckKnownEntry(instream, 1); } zipFile.Close(); } } finally { store.DeleteFile(tempFile); } } }
public void RoundTrip() { string tempFile = GetTempFilePath(); Assert.IsNotNull(tempFile, "No permission to execute this test?"); tempFile = Path.Combine(tempFile, "SharpZipTest.Zip"); using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { try { MakeZipFile(tempFile, "", 10, 1024, ""); using (IsolatedZipFile zipFile = new IsolatedZipFile(tempFile)) { foreach (ZipEntry e in zipFile) { Stream instream = zipFile.GetInputStream(e); CheckKnownEntry(instream, 1024); } zipFile.Close(); } } finally { store.DeleteFile(tempFile); } } }
public void BasicEncryptionToDisk() { const string TestValue = "0001000"; string tempFile = GetTempFilePath(); Assert.IsNotNull(tempFile, "No permission to execute this test?"); tempFile = Path.Combine(tempFile, "SharpZipTest.Zip"); using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedZipFile f = IsolatedZipFile.Create(tempFile)) { f.Password = "******"; StringMemoryDataSource m = new StringMemoryDataSource(TestValue); f.BeginUpdate(); f.Add(m, "a.dat"); f.CommitUpdate(); } using (IsolatedZipFile f = new IsolatedZipFile(tempFile)) { f.Password = "******"; // TODO: Testing is not yet ported - Assert.IsTrue(f.TestArchive(true), "Archive test should pass"); } using (IsolatedZipFile g = new IsolatedZipFile(tempFile)) { g.Password = "******"; ZipEntry ze = g[0]; Assert.IsTrue(ze.IsCrypted, "Entry should be encrypted"); using (StreamReader r = new StreamReader(g.GetInputStream(0))) { string data = r.ReadToEnd(); Assert.AreEqual(TestValue, data); } } store.DeleteFile(tempFile); } }
/// <summary> /// </summary> private void ZipFileFromISO(object sender, RoutedEventArgs e) { DeleteSampleText(); /* * Extract an archive using IsolatedZipFile ************************************************************* */ using (var zip = new IsolatedZipFile(SampleZipFileName)) { var entry = zip.GetEntry(SampleTextFileName); using (var streamIn = zip.GetInputStream(entry)) { using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { using (var streamOut = store.OpenFile(SampleTextFileName, FileMode.Create)) { streamIn.CopyTo(streamOut); } } } } /************************************************************* * */ DisplayMetrics("ZipFileFromISO", false); }