Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Zipping A File then Renaming it...

Status
Not open for further replies.

PaidtheUmpire

Programmer
Jan 4, 2004
105
AU
Is it possible to do the following through Delphi 7.

1) Zip a file to a .zip file. AutoGen.txt ----> AutoGen.zip
2) Rename the zip file to a different type. AutoGen.zip --> AutoGen.ptu

Any ideas?
Thanks for any help.

Paid The Umpire

Delphi, Delphi, Delphi. Oi! Oi! Oi!
 
Yes, but you would need a Zip library to create the Zip file (there are a number of open source libraries available).

If you change the extension, it will no longer be recognised as a Zip file (but would still be one). I would guess that programs like WinZip would not UnZip it because of the extension, but your program could (or you could rename it back to .zip before UnZipping).


Hope this helps.

[vampire][bat]
 
Delphi 7 has the ZLib unit which provides compression. I use it in an application and it seems to work well and is easy to use. The compressed files can have any file extension you want.

Andrew
Hampshire, UK
 
I use the Zipmaster component, which is also easy to use and allows the same sort of options that you get with winzip. Update, refresh etc
But you do have to bundle a couple of libarys (dll's which are supplied) with your application.




[red]GNBM 4th Feb[/red] More on and other neat UK stuff at forum1091
Steve: Delphi a feersum engin indeed.
 
Try Abbrevia. You can find it on sourceforge.

I've also tried lib and I have to say it was better than I believed.

The good thing with the zlib is that you can compress streams directly.



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-"There is always another way to solve it, but I prefer my way.
 
I've also used Abbrevia and have had no complaints thus far.

Clive
Runner_1Revised.gif

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer." (Paul Ehrlich)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
I use ZipForge from componentace.com. Great component, easy to use and doesnt need DLL's.

[bobafett] BobbaFet [bobafett]
Code:
if not Programming = 'Severe Migraine' then
                       ShowMessage('Eureka!');
 
Renaming is fairly simple use either of these functions:
[ul]
[li][tt]Rename[/tt] in the [tt]System[/tt] unit
syntax: [tt]procedure Rename(var F; Newname: string);
[/tt]

This one assumes the file F exists, and is of any type[/li]
[li][tt]RenameFile[/tt] in the [tt]SysUtils[/tt] unit.
syntax : [tt]function RenameFile(const OldName, NewName: string): Boolean;[/tt]
It returns a true if successful, otherwise false
[/li]
[/ul]
Check out the Delphi help on either of these functions.

Hope that helps.

Cheers,
Chris [pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top