ドットネットでIonic.Zip
を使用しました。ここに私のHTMLとJavaScriptコードをここ
<div>
<input type="password" id="pass" placeholder="Set Password" />
<button type="submit" class="cutomDownloadCCDA">Zip</button>
</div>
<script>
$('.cutomDownloadCCDA').click(function(e) {
//window.location.href = "Home/Zip";// Simple Way
var password = $('#pass').val();
$('#downloadFrame').remove(); // This shouldn't fail if frame doesn't exist
$('body').append('<iframe id="downloadFrame" style="display:none"></iframe>');
$('#downloadFrame').attr('src', '/Home/Zip?password=' + password);
});
</script>
は
public void Zip(string password)
{
using (ZipFile zip = new ZipFile())
{
string xml = "Your XML Data";
var newStream = new MemoryStream();
var newWriter = XmlWriter.Create(newStream);
newWriter.WriteRaw(xml);
newStream.Position = 0;
newWriter.Flush();
newStream.Seek(0, SeekOrigin.Begin);
// Ist File
ZipEntry e = zip.AddEntry("test.xml", newStream);
e.Password = password;
e.Encryption = EncryptionAlgorithm.WinZipAes256;
// 2nd File
//ZipEntry f2 = zip.AddEntry("test1.xml", newStream);
//f2.Password = "456";
//f2.Encryption = EncryptionAlgorithm.WinZipAes256;
Response.ContentType = "application/zip";
Response.AddHeader("Content-Disposition", "attachment;filename=somefile.zip");
zip.Save(Response.OutputStream);
}
}
http://www.pageresource.com/jscript/jpass.htmの – brk
可能な重複[どのようにロックするためにMVCのアクションメソッドがされています/パスワードによるXMLファイルの保護?](http://stackoverflow.com/questions/12216247/how-to-lock-password-protect-an-xml-file) – Yaje
@ user2181397私のファイルのパスワードを設定したいダウンロードする。私は、ページにパスワードを追加することに興味がありません –