Esempio n. 1
0
        private void WriteAnArchive(string tarFileName)
        {
            using (FileStream ms = File.OpenWrite(tarFileName))
            {
                Assert.AreEqual(0, ms.Length);
                writer.SetBaseStream(ms);

                using (MemoryStream ms1 = new MemoryStream(Encoding.ASCII.GetBytes("This is a test")))
                {
                    writer.Add(ms1, "tf1");
                }

                using (MemoryStream ms2 = new MemoryStream(Encoding.ASCII.GetBytes("This is a test")))
                {
                    writer.Add(ms2, "adir2/a/tf2", DateTime.Now);
                }

                writer.AddDirectory("adir/");
                writer.AddDirectory("adir2/a", DateTime.Now);
                writer.Dispose();
            }

            Assert.IsTrue(File.Exists(tarFileName), "archive exists");
            Assert.IsTrue(File.ReadAllBytes(tarFileName).Length > 0, "archive has contents");
        }