在Silverlight中创建zip [英] Create zip in silverlight
本文介绍了在Silverlight中创建zip的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨!
我已经编写了一个简单的程序来在Silverlight中创建zip文件,并且在将zip文件保存在本地磁盘上时遇到了问题.每次尝试执行此操作时,我都会收到错误消息不允许进行文件操作.拒绝访问路径("path ..."))是否有任何方法可以在没有IsolatedStorageFile的情况下进行?我尝试将zip文件保存在我的项目文件夹中,但没有帮助.
Hi !
I''ve to write a simply program to create zip file in silverlight and I''ve problem with saving my zip file on local disk. Every time I try to do that I receive error "File operation not permitted. Access to path ("path...") is denied" Is there any way to do that without IsolatedStorageFile ? I try to save zip file in my project folder but it didn''t help.
推荐答案
您可以从常规的浏览器内置Silverlight应用访问本地文件系统,但只能通过另存为"对话框(请参见 ^ ]),并且此对话框必须是用户启动的(例如在按钮单击处理程序上).
例如:
You can access the local file system from a regular in-browser Silverlight app, but only through a "Save as" dialog (see SaveFileDialog Class[^]), and this dialog must be user-initiated (like on a button click handler).
For example:
private void saveButton_Click(object sender, RoutedEventArgs e)
{
SaveFileDialog sfdlg = new SaveFileDialog();
sfdlg.Filter = "ZIP Files (*.zip)|*.zip";
if (true == sfdlg.ShowDialog())
{
using (Stream fs = sfdlg.OpenFile())
{
// use the stream "fs"
}
}
}
除非将其配置为在浏览器外运行,否则无法从Silverlight应用程序访问客户端文件系统.即使这样,您也只能访问在客户端系统上创建的特殊文件夹.这是安全的事情.
You cannot access the client side file system from a Silverlight app unless it''s configured to run out-of-browser. Even then, you can only access a special folder created on the client system. It''s a security thing.
这篇关于在Silverlight中创建zip的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文