wp7 利用ZipOutputStream压缩.txt文件问题

June1991 2011-12-22 09:55:14
//压缩
private static void CreateZipFile(string filesPath, string zipFilePath)
{
using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
{
if (isf.FileExists(filesPath))//判断文件夹是否存在
{
MessageBox.Show("文件夹不存在");
}
}
using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
{
if (isf.DirectoryExists(Used.strSignInPath))//判断文件是否存在
{
MessageBox.Show("文件不存在");
return;
}
string[] filenames = isf.GetFileNames(filesPath);
try
{
using (ZipOutputStream s = new ZipOutputStream(isf.CreateFile(zipFilePath)))
{
s.SetLevel(9);
byte[] buffer = new byte[4096];
foreach (string file in filenames)
{
ZipEntry entry = new ZipEntry(file);
entry.DateTime = DateTime.Now;
s.PutNextEntry(entry);
using (FileStream fs = File.OpenRead(file))
{
int sourceBytes;
do
{
sourceBytes = fs.Read(buffer, 0, buffer.Length);
s.Write(buffer, 0, sourceBytes);
} while (sourceBytes > 0);
}
}
s.Finish();
s.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
文件夹和.txt文件都是用IsolatedStorageFile创建的为什么压缩不成功呢?
...全文
146 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
June1991 2011-12-23
  • 打赏
  • 举报
回复
 using (var fs = isf.OpenFile(file,FileMode.OpenOrCreate,FileAccess.Read))
June1991 2011-12-23
  • 打赏
  • 举报
回复

private static void CreateZipFile(string filesPath, string zipFilePath)
{
using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
{
string[] filenames = isf.GetFileNames(filesPath);
try
{
using (ZipOutputStream s = new ZipOutputStream(isf.CreateFile(zipFilePath)))
{
s.SetLevel(9);
byte[] buffer = new byte[4096];
foreach (string file in filenames)
{
ZipEntry entry = new ZipEntry(file);
entry.DateTime = DateTime.Now;
s.PutNextEntry(entry);
using (FileStream fs = File.OpenRead(file))
{
int sourceBytes;
do
{
sourceBytes = fs.Read(buffer, 0, buffer.Length);
s.Write(buffer, 0, sourceBytes);
} while (sourceBytes > 0);
}
}
s.Finish();
s.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}


using (FileStream fs = File.OpenRead(file))
到这里就无法执行了!
DrSmart 2011-12-22
  • 打赏
  • 举报
回复
嗨,wp7解压东西太可怜了
June1991 2011-12-22
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 drsmart 的回复:]
嗨,wp7解压东西太可怜了
[/Quote]
我不是解压 是压缩
内容概要:本文聚焦于高维多阶段随机规划问题,深入研究了正则化分解方法与马尔可夫过程在刻画不确定性动态演化中的应用,并提供了完整的Python代码实现。通过引入正则化技术有效降低了高维随机优化问题的计算复杂度,结合马尔可夫链建模多阶段决策过程中的不确定性传播机制,提升了模型在复杂动态环境下的求解效率与鲁棒性。研究涵盖了问题建模、算法设计、数值求解及结果分析全过程,具有较强的理论深度与工程实践价值; 适合人群:具备一定运筹学、优化理论基础及Python编程能力,从事智能决策、人工智能、能源系统优化、金融工程等相关领域的科研人员、高校研究生以及工业界研发工程师; 使用场景及目标:①应用于电力系统调度、供应链管理、金融资产配置等存在多阶段不确定性的复杂决策场景;②掌握高维随机规划的建模思路与高效求解技术,深入理解正则化方法与马尔可夫过程在实际优化算法中的融合机制与实现路径; 阅读建议:建议结合提供的Python代码进行动手实践,重点关注算法实现细节、参数敏感性分析与收敛性验证,鼓励在不同应用场景中迁移和改进该方法,进一步探索其在分布鲁棒优化、动态规划等前沿方向的扩展潜力。

7,655

社区成员

发帖
与我相关
我的任务
社区描述
Windows Phone是微软发布的一款手机操作系统,它将微软旗下的Xbox LIVE游戏、Zune音乐与独特的视频体验整合至手机中。
社区管理员
  • Windows客户端开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧