PC Review


Reply
Thread Tools Rate Thread

determine when zipping is finished

 
 
Benjamin Bittner
Guest
Posts: n/a
 
      1st Sep 2004
hallo ng,
first of all, for the zipping progress i use the ziplib from
http://www.icsharpcode.net/OpenSourc...b/Default.aspx

now to my problem.
im trying to build a little application for zipping our webservers logfiles.
after zipping all files, i've tried to delete all files, but i couldnt. i
got an error message that i cannot delete a file, because it is still in
use. Here my two functions for that:

Function ZipAll()
Dim datei As FileInfo
For Each datei In retFiles
Dim zipPfad As String =
datei.FullName.ToString.Replace(datei.Extension.ToString, ".zip")
Zip(datei.FullName.ToString, zipPfad)
Next
End Function

Function Zip(ByVal fileIn As String, ByVal fileOut As String) As Boolean
Dim boReturn As Boolean
Try
Dim strFileName As String = fileIn
Dim s As ZipOutputStream = New
ZipOutputStream(File.Create(fileOut))
s.SetLevel(5)
Dim fs As FileStream = File.OpenRead(strFileName)
Dim buffer() As Byte = New Byte(fs.Length) {}
fs.Read(buffer, 0, fs.Length)
Dim entry As ZipEntry = New
ZipEntry(Path.GetFileName(strFileName))
s.PutNextEntry(entry)
s.Write(buffer, 0, buffer.Length)
s.Finish()
s.Close()
boReturn = True
Catch
boReturn = False
End Try
Return boReturn
End Function

retFiles is an arraylist with strings pointing to our logfiles.
i have a button for zipping, and one for deleting:

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Button2.Enabled = False
Button3.Enabled = False
ZipAll()
Button2.Enabled = False
Button3.Enabled = True
End Sub

This is the click event for the zpping button. this is my little try to
enable the button when the zipall() has finished. but this didnt worked. the
delete button gets enabled, but my app crashes when pressed, because it
tries to delete files which are currently in use.

is there any way to determine if the zip function has really finished, or
does anybody got an idea for a workaround?

thx in advance
regards benjamin


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to determine when a process has finished initial loading =?Utf-8?B?Tm90cmUgUG91YmVsbGU=?= Microsoft Dot NET Framework 2 20th Sep 2006 07:09 PM
How to determine when a DataGridView's DataSource is finished being populated johneevo Microsoft ADO .NET 2 5th Apr 2006 06:31 PM
How to Determine PrintJob is Finished with VBA SFatz Microsoft Excel Programming 2 28th Jan 2005 01:05 PM
Determine wether code execution is finished jokobe Microsoft Access Form Coding 0 11th Aug 2004 08:01 AM
How can I determine that a file has finished being written? Tim Meagher Microsoft Dot NET 0 2nd Jul 2003 09:21 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:49 AM.