本文介绍了如何纠正问题'该进程无法归档'path \',该文件已被另一个进程使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我运行下面的代码,有时它''显示错误,如

该进程无法找到文件"\ path",该文件已被另一个进程使用"


谁能告诉我代码中的任何问题.




i run the below code, sometimes its'' showing error like

''the process cannot find file ''\path'' it is used by another process''


can anyone tell me any problem in my code.


// code for Zip a multiple files//


Crc32 crc = new Crc32();
string attach = AppDomain.CurrentDomain.BaseDirectory + "Documents/" + "Attachments.zip";

if (File.Exists(attach))
{
    File.Delete(attach);
}

ZipOutputStream s = new ZipOutputStream(File.Create(attach));
s.SetLevel(9); // 0 - store only to 9 - means best compression



string names = hidfield.Value;
string[] strNames = names.Split('','');

for (int i = 0; i < strNames.Length; i++)
{

    FileStream fs = File.OpenRead(AppDomain.CurrentDomain.BaseDirectory + "Documents/" + strNames[i]);

    byte[] buffer = new byte[fs.Length];
    fs.Read(buffer, 0, buffer.Length);

    ZipEntry entry = new ZipEntry(ZipEntry.CleanName("Documents/" + strNames[i]));
    entry.DateTime = DateTime.Now;
    entry.Comment = " ";
    entry.ZipFileIndex = i;
    entry.Size = fs.Length;
    fs.Close();
    crc.Reset();
    crc.Update(buffer);
    entry.Crc = crc.Value;
    s.PutNextEntry(entry);
    s.Write(buffer, 0, buffer.Length);
}

s.Finish();
s.Close();

推荐答案


这篇关于如何纠正问题'该进程无法归档'path \',该文件已被另一个进程使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 19:04