In my application, I need to convert the file which is dropped by user to a ZIP file, in a temporary folder. I am using DotNetZip for this purpose by writing something like this.
zip.AddFile("DroppedFile.xyz");
zip.Save("C:\\Temp\MyZip.zip");
I was able to achieve the same by creating a FileInfo
type and using the CopyTo
method by writing the below code.
FileInfo myfile = new FileInfo("C:\\DroppedFile.xyz");
myfile.CopyTo("C:\\Temp\MyZip.zip");
I get the same result, both create a ZIP file in the temp directory. But what I want to know is that is there something like I shouldn't use the second approach because I feel it is not being used for its intended purpose (Correct me if I'm wrong). Please let me know the difference between both the approaches.