title: What would cause files being added to a zip file to not be included in the zip?
body: <p>I work with a program that takes large amounts of data, turns the data into xml files, then takes those xml files and zips them for use in another program. Occasionally, during the zipping process, one or two xml files gets left out. It is fairly rare, once or twice a month, but when it does happen it's a big mess. I am looking for help figuring out why the files don't get zipped and how to prevent it. This code is straightforward: </p>
  
  <pre><code>public string AddToZip(string outfile, string toCompress)
      {
          if (!File.Exists(toCompress)) throw new FileNotFoundException("Could not find the file to compress", toCompress);
  
  
          string dir = Path.GetDirectoryName(outfile);
          if(!Directory.Exists(dir))
          {
              Directory.CreateDirectory(dir);
          }
  
          // The program that gets this data can't handle files over 
          // 20 MB, so it splits it up into two or more files if it hits the 
          // limit.
          if (File.Exists(outfile))
          {
              FileInfo tooBig = new FileInfo(outfile);
              int converter = 1024;
              float fileSize = tooBig.Length / converter; //bytes to KB
              fileSize = fileSize / converter;  //KB to MB
  
              int limit = CommonTypes.Helpers.ConfigHelper.GetConfigEntryInt("zipLimit", "19");
              if (fileSize &gt;= limit)
              {
                  outfile = MakeNewName(outfile);
              }
          }
  
          using (ZipFile zf = new ZipFile(outfile))
          {
              zf.AddFile(toCompress,"");
              zf.Save();
          }
  
          return outfile;          
      }
  </code></pre>
  
  <p>Ultimately, what I want to do is have a check that sees if any xml files weren't added to the zip after the zip file is created, but stopping the problem in its tracks are best overall. Thanks for the help.</p>