473,493 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problems creating a Tar Archive with SharpZipLib

The following piece of code should turn the folder IN and its subfolders
into a single tar file
located in the folder OUT:

using ICSharpCode.SharpZipLib;
using ICSharpCode.SharpZipLib.Tar;

public static void Create_Tar_Archive(string IN,string OUT)
{
//IN and OUT are directories
if (IN=="" || OUT=="" || !System.IO.Directory.Exists(IN)
|| !System.IO.Directory.Exists(OUT)) return;
string OutName=OUT+"\\"+System.IO.Path.GetFileName(IN)+". tar";

Stream stmout=new FileStream(OutName,FileMode.OpenOrCreate);
TarArchive
TA=ICSharpCode.SharpZipLib.Tar.TarArchive.CreateOu tputTarArchive(stmout);
TarEntry TE=TarEntry.CreateEntryFromFile(IN);
TA.WriteEntry(TE,true);
TA.CloseArchive();
stmout.Close();
}

The code seems to work but inside the output tar archive the file paths are
absolute and not relative (they start with C:\...),
and so any attemp to "decompress" the archive into a target folder fails
(illegal paths).

I would like to know how to create a tar archive with relative file paths,
i.e. with a root directory named like System.IO.Path.GetFileName(IN) and the
relative subfolders inside it,
or simply with the files and subfolders of the directory IN in first place
with relative paths.

I don't know how to create the TarEntries to achieve that (the documentation
is not so clear).

Code or links are welcome. Thank you in advance.
Nov 16 '05 #1
1 9648

"Flix" <wr***@newsgroup.comeon> ha scritto nel messaggio
news:cb**********@lacerta.tiscalinet.it...
[......]
I would like to know how to create a tar archive with relative file paths,
i.e. with a root directory named like System.IO.Path.GetFileName(IN) and the relative subfolders inside it,


I've solved it changing the current directory with
System.IO.Directory.SetCurrentDirectory(new_path) before any operation, and
providing the function with a relative path directory.
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2360
by: Eric Nelson | last post by:
I get a gzipped tar archive e-mailed to me every day. Thanks to help from this newsgroup I have a daily c# program that scans my outlook mail, finds the archive and saves it to a file. Now I'd...
2
2800
by: Christer | last post by:
Hi all, I've been trying to use the SharpZipLib as it sounds promising and a lot of people refer to it in discussions on compression. However, I am getting some bad output, when I try to unzip a...
9
2750
by: Harry | last post by:
I am accumulating over 80 pages per day into an archive that I will need to be able to present sequentially to viewers. Using html to viewing a page, then click on back to return to my archive...
1
9238
by: BeanDog | last post by:
I know this is a horse that's been beated good and dead, but I *still* can't find a good solution to this. I suppose I should post this on SharpZipLib's forums, but I signed up and they never sent...
6
7779
by: JezB | last post by:
From a windows application, I want to provide an "archive" facility which will scan a specific directory and put specific files into some single "Archive file", a bit like a zip-file I guess, but...
1
3492
by: Brian Henry | last post by:
I keep getting this error when decompressing any zip files.. ICSharpCode.SharpZipLib.ZipException: Wrong Local header signature: 0xB023867F at...
4
7796
by: Sam | last post by:
Hi all, Does someone knows if I can use this librairy (ICSharpCode.SharpZipLib.Zip) for free ? It is used to zip files (as you can probably guess). Thank you very much. Samuel
3
36967
by: CodeTalker | last post by:
I am new to VB.NET and SharpZipLib for that matter. I need the ability to zip a single file. I have found many examples of unzipping a zip file but not one to actually zip one. If anyone has an...
34
5296
by: Alexnb | last post by:
Gerhard Häring wrote: No, it didn't work, but it gave me some interesting feedback when I ran it in the shell. Heres what it told me: Traceback (most recent call last): File...
0
7119
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6989
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6873
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4889
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1400
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
644
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.