, 나는이 코드를 가지고 :덮어 쓰기 항목이 나는 데 문제
DirectoryInfo di = new DirectoryInfo(dir);
FileInfo[] rgFiles = di.GetFiles();
DirectoryInfo[] d = di.GetDirectories();
if(rgFiles != null && d != null) {
foreach (FileInfo fi in rgFiles)
{
foreach (DirectoryInfo dii in d)
{
using (ZipFile zip = ZipFile.Read(locateZipFile()))
{
zip.AddFile(fi.FullName, "");
zip.AddDirectory(dii.FullName,dii.Name);
toolStripStatusLabel1.Text = "Inserting " + fi.Name;
toolStripStatusLabel1.Text = "Inserting " + dii.Name + " and all of it's contents";
MessageBox.Show("Inserted the file " + fi.Name);
MessageBox.Show("Inserted the folder " + dii.Name + " and all contents in it.");
zip.Save();
}
}
}
모든 것이 잘 작동을하지만 우편에 동일라는 파일을 추가하려고하고있을 때, 그것을 그것을 덮어 쓰지 않습니다. 나는 그것을 원합니다. 어떻게 할 수 있는지에 대한 아이디어가 있습니까? 감사. 라인
zip.AddFile(fi.FullName, "");
이름이 이미 항목에 존재하는 경우 테스트해야하기 전에
감사합니다. 하지만 이것은 디렉토리에서 작동하지 않습니까? 디렉토리라면 어떻게 될까요? – user1568364
GetDirectoryName 메서드를 사용할 수 있습니다 : Path.GetDirectoryName (fi.FullName); (이것을 응답으로 표시하는 것을 잊지 마십시오!)) –