Hello,
I am trying the ZIP control for silverlight, but i keep having an issue.
I am trying to Compress and Uncompress a stream which is getting read from a WAV file.
the issue is that the size of the stream before compression and after decompression is different. this causes the uncomressed stream to be invalid and therefore not to be played by the basic media element of silverlight.
I am attaching a sample of code to demonstrate the zip and unzip methods that i use.
I wanted to also note that I did encounter the decompress example which is online here. but it does not help me since dealing with string will not give me the expected result.
Thank you in advance for nay help about this...
kob490.
I am trying the ZIP control for silverlight, but i keep having an issue.
I am trying to Compress and Uncompress a stream which is getting read from a WAV file.
the issue is that the size of the stream before compression and after decompression is different. this causes the uncomressed stream to be invalid and therefore not to be played by the basic media element of silverlight.
I am attaching a sample of code to demonstrate the zip and unzip methods that i use.
string wavFilePath = @"C:\1\cheer.wav";
string wavFileNewPath = @"C:\1\cheerNew.wav";
string zipFilePath = @"c:\1\123.zip";
private void btnCompress(object sender, RoutedEventArgs e)
{
FileStream fs = new FileStream(wavFilePath, FileMode.Open);
SizeBefore.Text = fs.Length.ToString();
using (ZipPackage zipFile = ZipPackage.CreateFile(zipFilePath))
{
zipFile.AddStream(fs, "cheer.wav", ZipCompression.Default, DateTime.Now);
zipFile.Close(true);
}
}
private void btnUncompress(object sender, RoutedEventArgs e)
{
using (ZipPackage zipFile = ZipPackage.OpenFile(zipFilePath, FileAccess.Read))
{
ZipPackageEntry zipEntry = zipFile.ZipPackageEntries[0];
Stream strm = zipEntry.OpenInputStream();
byte[] Bytes = new byte[strm.Length];
strm.Read(Bytes, 0, (int)strm.Length);
using (FileStream fs = new FileStream(wavFileNewPath, FileMode.Create))
{
fs.Write(Bytes, 0, Bytes.Length);
fs.Close();
}
}
}
I wanted to also note that I did encounter the decompress example which is online here. but it does not help me since dealing with string will not give me the expected result.
Thank you in advance for nay help about this...
kob490.