Exemple #1
0
        internal static Stream TarInMemory(DirectoryInfo directory, MemoryStream streamInMem)
        {
            var sourceDirectory = directory.FullName;

            using (TarArchive tarArchive = TarArchive.CreateOutputTarArchive(streamInMem))
            {
                tarArchive.IsStreamOwner = false;
                tarArchive.SetRootPath(sourceDirectory);

                addDirectoryFilesToTar(tarArchive, sourceDirectory, true);
                return(streamInMem);
            }
        }
Exemple #2
0
        public static FileInfo Tar(string sourceDirectory, string destTarPath)
        {
            if (File.Exists(destTarPath))
            {
                File.Delete(destTarPath);
            }
            using (Stream outStream = File.Create(destTarPath))
                using (TarArchive tarArchive = TarArchive.CreateOutputTarArchive(outStream))
                {
                    tarArchive.SetRootPath(sourceDirectory);

                    addDirectoryFilesToTar(tarArchive, sourceDirectory, true);
                    return(new FileInfo(destTarPath));
                }
        }