I have strange thing with compressing file to temp file. When generating temp filename and compress I getting exception but when I set static filename there is no problems and exceptions. What is wrong?
tmp0 = Path.GetTempFileName();
WriteSomeDataToFileAndClose(tmp0);
tmp1 = Path.GetTempFileName();
using (var fileStream = new FileStream(tmp1, FileMode.CreateNew))
{
using (ZipArchive zip2 = new ZipArchive(fileStream, ZipArchiveMode.Create))
{
zip2.CreateEntryFromFile(tmp0, Path.GetFileNameWithoutExtension(tmp0), CompressionLevel.Fastest);
}
}
Error:
System.Windows.Markup.XamlParseException: The invocation of the constructor on type