A:
You are extracting the whole file to the output file. When you have obtained the file, you are copying the file using CopyFile function. So the output file will have the same name and the same size as the original file. So when you extract the file again and extract the contents of the output file again, the extracted content is already extracted from the original file and hence you get the same result again. If you want to extract contents of a file to a new file, you need to extract the contents to a temp file, rename the temp file as the name you want, and then copy the renamed file.
Hence if you want to achieve the desired output as mentioned in your question, you should do as shown below:
//Get the file to be encrypted
FileStream fileStream = null;
FileStream encryptedFileStream = null;
using (FileStream stream = File.OpenRead(encryptedFile))
using (Stream s = new FileStream(fileName, FileMode.Open, FileAccess.ReadWrite))
using (encryptedFileStream = new FileStream(fileName, FileMode.Create))
{
s.CopyTo(encryptedFileStream);
}
//Rename the temp file, extract the content and rename it
string oldFile = fileName;
string tempFile = Path.GetTempFileName();
FileStream encryptedStream = null;
using (encryptedFileStream = new FileStream(tempFile, FileMode.Create))
using (Stream s = File.OpenRead(fileName))
using (encryptedStream = new FileStream(tempFile, FileMode.Open, FileAccess.ReadWrite))
{
s.CopyTo(encryptedStream);
File.Copy(tempFile, oldFile);
}
//Extract the content of the new file, which is encryptedFileStream
using (Stream s = File.Open(encryptedFile, FileMode.Open))
using (Stream encryptedStream = File.Open(tempFile, FileMode.Open))
{
//Copy the content to a new file with a new name
File.Copy(encryptedStream, new FileStream(fileName, FileMode.Create));
}
See this SO question for details.
Don't miss the big Liverpool FC stories by getting our newsletter Sign me ac619d1d87
Related links:
https://ar.kfimmigrationcanada.ca/profile/haraldphylburtphylburt/profile
https://www.cakeresume.com/portfolios/ps-tray-factory-v3-2-incl-crack-precracked-just
https://mariajackson1985.wixsite.com/consmefunbuck/post/surgical-steel-carcass-tampew
https://theivinatuthi.wixsite.com/dautamerli/post/idman-605-crack-free-download-updated-2022
コメント