[Mono-list] how to compress a directory?

Rolando Martinez rolandomartinezg at gmail.com
Tue Oct 28 10:39:33 EDT 2008


Thank you very much Robert :)
it was very useful for me :P

Regards,
Rolando.

Rolando Martinez wrote:
> Hi,
> I have a web app and I would like what is the correct way to compress a
> directoy inside my application?
> Currently I have the next code, but I have the problem that when the user
> download the file, he can see the complete path inside of tar.gz file
> (var/www/webapp/app_data/directory)...I would like to have just the folder
> inside of tar.gz :)

Untested:

DirectoryInfo di = new DirectoryInfo (localeFolder);
...
process.StartInfo.Arguments = String.Format("-czvf {0} -C {1} {2}",
       nameOfGzipFile, di.Parent.FullName, di.Name);
...



>
>
>        public static bool Compress(string localeFolder, string
> nameOfGzipFile)
>         {
>             System.Diagnostics.Process process = new
> System.Diagnostics.Process ();
>             process.StartInfo.FileName = "tar";
>             process.StartInfo.Arguments = " -czvf " + nameOfGzipFile +" "
+
> localeFolder;
>             process.Start ();
>             process.WaitForExit ();
>
>             return (process.ExitCode == 0);
>
>         }
>
> Thank you !!!
> Rolando.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20081028/546a99ee/attachment.html 


More information about the Mono-list mailing list