如何在Cryptostream中使用自定义图标创建文件? [英] How Do I Create A File With A Custom Icon Within A Cryptostream?

查看:82
本文介绍了如何在Cryptostream中使用自定义图标创建文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个CryptoStream,它接受一个文件然后加密所述文件并输出一个扩展名为.enc的新文件。如何在CryptoStream方法中为这个新的加密文件添加一个图标?



这是我的CryptoStream方法:



I have a CryptoStream that takes a file and then encrypts said file and outputs a new file with the extension .enc how do i add a icon to this new encrypted file within the CryptoStream method?

This is my CryptoStream method:

using (FileStream inputFileStream = File.Open(inputFile, FileMode.Open))
                   using (FileStream outputFileStream = File.Open(encryptedFile, FileMode.Create))
                   {
                       using (AesCryptoServiceProvider aesCryptoServiceProvider = new AesCryptoServiceProvider())
                       {

                           aesCryptoServiceProvider.BlockSize = 128;
                           aesCryptoServiceProvider.KeySize = 256;
                           aesCryptoServiceProvider.Key = keyBytes;
                           aesCryptoServiceProvider.IV = ivBytes;

                           ICryptoTransform cryptoTransform = aesCryptoServiceProvider.CreateEncryptor();

                           using (CryptoStream cryptoStream = new CryptoStream(outputFileStream, cryptoTransform, CryptoStreamMode.Write))
                           {
                               byte[] buffer = new byte[inputFileStream.Length];
                               inputFileStream.Read(buffer, 0, buffer.Length);
                               cryptoStream.Write(buffer, 0, buffer.Length);
                               MessageBox.Show("The File Was Successfully Encrypted", "Encrypted!", MessageBoxButton.OK, MessageBoxImage.Information);
                           }
                       }
                   }





图标的路径设置为用户并显示在名为OpenIcon.text的文本框中!



可能无法在CryptoStream中向文件添加图标,因此如果有人有任何其他想法关于如何在CryptoStream之后向加密文件添加图标?



The path to the icon is set by the user and is displayed in a textbox called OpenIcon.text!

It may not be possible adding a icon to the file in the CryptoStream so if anyone has any other ideas on how one would add an icon to the encrypted file after the CryptoStream?

推荐答案

首先,您不能将图标分配给流,因此请先保存文件。那么可能 IconHandlers 可以完成你的工作但不是那么容易。

您需要创建一个shell扩展处理程序来执行此操作,最好使用C ++之类的语言执行此操作。



查看此完整文章MSDN

https:// msdn.microsoft.com/en-us/library/windows/desktop/cc144122(v=vs.85).aspx [ ^ ]



希望,它有帮助:)
First of all, you can not assign an icon to a stream so save the file first. Then probably, IconHandlers can do your job but it's not that easy.
You need to create a shell extension handler to do this and preferably you do this using language like C++.

Check this complete article in MSDN
https://msdn.microsoft.com/en-us/library/windows/desktop/cc144122(v=vs.85).aspx[^]

Hope, it helps :)


这篇关于如何在Cryptostream中使用自定义图标创建文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆