I'm writing a C# .NET WinForms app where I need to create a zip file (using DotNetZip) consisting of items of the following types:
System.Drawing.Image someimage
Microsoft.DirectX.AudioVideoPlayback.Audio someaudio
Microsoft.DirectX.AudioVideoPlayback.Video somevideo
Problem: In all the code examples I've found in which an image, audio or video file is converted to a byte array or Base64 string, the items are converted using the files' original filepaths...
byte() MediaInBytes = File.ReadAllBytes(originalfilepath);
Since the resulting zip file may be opened on another computer other than the one it was created on, I cannot use each image, audio or video file's original filepath because those image, audio or video files may not exist on another computer. Once I add an image, audio or video file, the original filepath should no longer be used.
So I'm left with two options:
1. Find a way to add someimage, someaudio and somevideo to a zip archive created with DotNetZip without converting them to Base64 string or byte array first, or
2. Find a way to write the values of someimage, someaudio and somevideo to a temp file so I can add them from there. Remember, to add an item to a DotNetZip zip file, the item must originate from a filepath:
Ionic.Zip.ZipEntry someEntry = zip.AddFile(filepath);
Any help will be greatly appreciated.
What I have tried:
byte() MediaInBytes = File.ReadAllBytes(someimage);
byte() MediaInBytes = File.ReadAllBytes(someaudio);
byte() MediaInBytes = File.ReadAllBytes(somevideo);
Ionic.Zip.ZipEntry someEntry = zip.AddFile(filepath);