【问题标题】:Having some issues while using chilkat library for zipping/unzipping使用 chilkat 库进行压缩/解压缩时遇到一些问题
【发布时间】:2011-07-22 05:05:56
【问题描述】:

我正在使用 chilkat 库来压缩一些文件并将它们移动到另一个路径。这在大多数情况下都可以正常工作,但有时会在我的 exe 所在的路径中生成一个 tmp 文件。现在我在 3 个月后突然检查,这个文件已经占用了 2 GB 的硬盘。以下是我的代码:

 public static bool MoveShopTRRFiles() {
            //string fullfilepath;
            Zip zip = new Zip();
            bool unlocked = zip.UnlockComponent("abc");
            if (!unlocked) {
                //MessageBox.Show(zip.LastErrorText);
                //return;
                return false;
            }
            if (Directory.Exists(_TRRPath)) {
            foreach (string filename in Directory.GetFiles(_TRRPath, "*.trr")) {
                if (!File.Exists(_ShopTRRPath + "\\" + GetShopName(filename) + ".zip")) {
                    zip.NewZip(_ShopTRRPath + "\\" + GetShopName(filename) + ".zip");
                } else {
                    zip.OpenZip(_ShopTRRPath + "\\" + GetShopName(filename) + ".zip");
                }
                try {
                    if(zip.GetEntryByName (filename.Substring(filename.LastIndexOf('\\') + 4))==null ){
                        zip.AppendOneFileOrDir(filename);
                    }

                    zip.WriteZipAndClose();                       
                    File.Delete(filename);
                } catch {

                }
            }
            return true;
        } else
            return false;
    }

【问题讨论】:

  • 如果您希望此程序安装在 UAC 环境中,写入 exe 路径可能是不可接受的。
  • 只是想知道是不是 chilkat 使这个临时文件在可执行路径中。这段代码作为一个计划任务运行,间隔为 30 秒

标签: c# zip chilkat


【解决方案1】:

现在,我正在删除应用程序文件夹中的临时文件。所以这暂时解决了问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多