C# Programming
11-10-2009, 08:30 AM
hi
i have problem with end of process.
i need to zip file - and after i zip - i need to do some thing with this zip file...
the problem is, although the messagebox appear - i noticed that the process is not end.
how i can know for sure that the process is end ?
my zip sample:
try{
if (File.Exists(@"c:\DaZIP\Bind.sdf"))
File.Delete(@"c:\DaZIP\Bind.sdf");
File.Copy(Application.StartupPath + @"\Bind.sdf", @"c:\DaZIP\Bind.sdf");
byte[] sampleBuffer = null;
ZipEntry sampleZipFile = null;
FileStream sampleFileStream = null;
ZipOutputStream sampleOutputStream = new ZipOutputStream(File.Create(Application.StartupPath + @"\Bind.zip"));
sampleOutputStream.Password = "12345";
sampleOutputStream.SetLevel(9);
foreach (string sampleFile in Directory.GetFiles(@"c:\DaZIP")) {
sampleZipFile = new ZipEntry(Path.GetFileName(sampleFile));
sampleOutputStream.PutNextEntry(sampleZipFile);
sampleFileStream = File.OpenRead(sampleFile);
sampleBuffer = new byte[sampleFileStream.Length];
sampleFileStream.Read(sampleBuffer, 0, sampleBuffer.Length);
sampleOutputStream.Write(sampleBuffer, 0, sampleBuffer.Length);
}
sampleOutputStream.Finish();
sampleOutputStream.Close();
}
catch (Exception ex){ MessageBox.Show(ex.Message ,"",0, MessageBoxIcon.Exclamation);
return;}
MessageBox.Show("End ZIP");
i work on VS2008 C# WinForm
i know that the process still work, because when i try to do somthing with the zip
file, i get error that the file is in use. and if i wait for 1-2 minute, i can do what i
want with this zip file.
i have problem with end of process.
i need to zip file - and after i zip - i need to do some thing with this zip file...
the problem is, although the messagebox appear - i noticed that the process is not end.
how i can know for sure that the process is end ?
my zip sample:
try{
if (File.Exists(@"c:\DaZIP\Bind.sdf"))
File.Delete(@"c:\DaZIP\Bind.sdf");
File.Copy(Application.StartupPath + @"\Bind.sdf", @"c:\DaZIP\Bind.sdf");
byte[] sampleBuffer = null;
ZipEntry sampleZipFile = null;
FileStream sampleFileStream = null;
ZipOutputStream sampleOutputStream = new ZipOutputStream(File.Create(Application.StartupPath + @"\Bind.zip"));
sampleOutputStream.Password = "12345";
sampleOutputStream.SetLevel(9);
foreach (string sampleFile in Directory.GetFiles(@"c:\DaZIP")) {
sampleZipFile = new ZipEntry(Path.GetFileName(sampleFile));
sampleOutputStream.PutNextEntry(sampleZipFile);
sampleFileStream = File.OpenRead(sampleFile);
sampleBuffer = new byte[sampleFileStream.Length];
sampleFileStream.Read(sampleBuffer, 0, sampleBuffer.Length);
sampleOutputStream.Write(sampleBuffer, 0, sampleBuffer.Length);
}
sampleOutputStream.Finish();
sampleOutputStream.Close();
}
catch (Exception ex){ MessageBox.Show(ex.Message ,"",0, MessageBoxIcon.Exclamation);
return;}
MessageBox.Show("End ZIP");
i work on VS2008 C# WinForm
i know that the process still work, because when i try to do somthing with the zip
file, i get error that the file is in use. and if i wait for 1-2 minute, i can do what i
want with this zip file.