专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Windows Mobile

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

发布时间:2010-05-30 01:01:36 文章来源:www.iduyao.cn 采编人员:星星草
wp7 利用ZipOutputStream压缩.txt文件问题
//压缩
  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创建的为什么压缩不成功呢?

------解决方案--------------------
嗨,wp7解压东西太可怜了
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: