473,545 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
+ 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.Sha rpZipLib;
using ICSharpCode.Sha rpZipLib.Tar;

public static void Create_Tar_Arch ive(string IN,string OUT)
{
//IN and OUT are directories
if (IN=="" || OUT=="" || !System.IO.Dire ctory.Exists(IN )
|| !System.IO.Dire ctory.Exists(OU T)) return;
string OutName=OUT+"\\ "+System.IO.Pat h.GetFileName(I N)+".tar";

Stream stmout=new FileStream(OutN ame,FileMode.Op enOrCreate);
TarArchive
TA=ICSharpCode. SharpZipLib.Tar .TarArchive.Cre ateOutputTarArc hive(stmout);
TarEntry TE=TarEntry.Cre ateEntryFromFil e(IN);
TA.WriteEntry(T E,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 9668

"Flix" <wr***@newsgrou p.comeon> ha scritto nel messaggio
news:cb******** **@lacerta.tisc alinet.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.Direc tory.SetCurrent Directory(new_p ath) 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
2369
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 like to unpack it, à là (cd targetdir; gunzip file|tar xvf -) How do I do this from the same c# program? Thanks for ideas & insight, Eric
2
2819
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 (correctly hand made) ..zip file via code. I DO get the right amount of files, however, some seem cut in half ... when viewing the output files...
9
2761
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 index is so awkward it is not useful for my presentations. Can javascript be used to create a powerpoint like presentation of html files (with gif...
1
9255
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 me a confirmation email, and I can't resign up with the same email address. Great. I'm trying to unzip from a byte array to a byte array using...
6
7787
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 more windows standard. Then I want to provide a function "Import from Archive" which will accept the name of such an archive file, and be able to...
1
3497
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 ICSharpCode.SharpZipLib.Zip.ZipInputStream.GetNextEntry() at BeneFTPHostService.BeneFTPHostService.ProcessQueue() in C:\reschinidev\benefits...
4
7798
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
36987
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 example of this I would GREATLY appreciate it.
34
5304
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 "<pyshell#10>", line 1, in <module> os.startfile("C:\Documents and Settings\Alex\My Documents\My
0
7475
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7771
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5982
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5343
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4958
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3465
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1900
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 we have to send another system
1
1023
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
720
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.