Stream converted to .wmv while zipping, but not playing

Jan 23, 2012 at 8:07 PM
Edited Jan 23, 2012 at 8:36 PM

Hello,

I am trying to Zip a stream to .wmv using Zipfile.addentry and saving the zipfile to the local directory.

And tried extracting it and tried to play the video. But the video is not playing.The Video has same size as original one after extracted also. I don't know what am I doing wrong? Please tell me, I am posting my code below.

 

   private void CreateZipArchive(string zipFilename)
        {
            string SavePath = @"C:\files\True_Zip_Sample.zip";

             string VidPath = @"C:\Temp\COUNT DOWN.WMV";

            
            FileStream stream = new FileStream(VidPath, FileMode.Open, FileAccess.Read);
            //string b64Vid = Base64Utility.FileToBase64(VidPath);
            //byte[] bVid = Convert.FromBase64String(b64Vid);
            //MemoryStream ms4 = new MemoryStream(bVid);
            //ms4.Seek(0, SeekOrigin.Begin);
                   
                    using (ZipFile zip = new ZipFile(Encoding.UTF8))
                    {
                        stream.Seek(0, SeekOrigin.Begin);
                        zip.AddEntry("Videos\\104.wmv", stream);
                        zip.Save(SavePath);
                    }

        }

        private void MyExtract()
        {
            string zipToUnpack = @"C:\files\TruSource_Zip_Sample.zip";
            string unpackDirectory = @"C:\files\Extracted Files";
            using (ZipFile zip1 = ZipFile.Read(zipToUnpack))
            {
                // here, we extract every entry, but we could extract conditionally
                // based on entry name, size, date, checkbox status, etc.  
                foreach (ZipEntry e in zip1)
                {
                    e.Extract(unpackDirectory, ExtractExistingFileAction.OverwriteSilently);
                }
            }
        }

private void ZipCreate_Click(object sender, EventArgs e)
        {
            try
            {
                string ZipName = "True_Zip_Sample";
                CreateZipArchive(ZipName);
                MyExtract();
            }
            catch (Exception ex)
            {
            }
        }

Thanks

Jan 23, 2012 at 9:28 PM
Edited Jan 23, 2012 at 9:36 PM
shyam206 wrote:

Hello,

I am trying to Zip a stream to .wmv using Zipfile.addentry and saving the zipfile to the local directory.

And tried extracting it and tried to play the video. But the video is not playing.The Video has same size as original one after extracted also. I don't know what am I doing wrong? Please tell me, I am posting my code below.

 

   private void CreateZipArchive(string zipFilename)
        {
            string SavePath = @"C:\files\True_Zip_Sample.zip";

             string VidPath = @"C:\Temp\COUNT DOWN.WMV";

            
            FileStream stream = new FileStream(VidPath, FileMode.Open, FileAccess.Read);
            //string b64Vid = Base64Utility.FileToBase64(VidPath);
            //byte[] bVid = Convert.FromBase64String(b64Vid);
            //MemoryStream ms4 = new MemoryStream(bVid);
            //ms4.Seek(0, SeekOrigin.Begin);
                   
                    using (ZipFile zip = new ZipFile(Encoding.UTF8))
                    {
                        stream.Seek(0, SeekOrigin.Begin);
                        zip.AddEntry("Videos\\104.wmv", stream);
                        zip.Save(SavePath);
                    }

        }

 

        private void MyExtract()
        {
            string zipToUnpack = @"C:\files\TruSource_Zip_Sample.zip";
            string unpackDirectory = @"C:\files\Extracted Files";
            using (ZipFile zip1 = ZipFile.Read(zipToUnpack))
            {
                // here, we extract every entry, but we could extract conditionally
                // based on entry name, size, date, checkbox status, etc.  
                foreach (ZipEntry e in zip1)
                {
                    e.Extract(unpackDirectory, ExtractExistingFileAction.OverwriteSilently);
                }
            }
        }

private void ZipCreate_Click(object sender, EventArgs e)
        {
            try
            {
                string ZipName = "True_Zip_Sample";
                CreateZipArchive(ZipName);
                MyExtract();
            }
            catch (Exception ex)
            {
            }
        }

 

Thanks

The above code works fine in windows 7 but not in Windows server 2008 r2.

 Windows Media Player encountered a problem while playing the file.