Beispiel #1
0
        internal static ZipArchive OpenArchive(string fileName, ZipArchiveMode mode)
        {
            ZipArchive result = null;

            int tries = 10;

            while (result == null && tries-- > 0)
            {
                try
                {
                    result = ZipFile.Open(fileName, mode);
                }
                catch (IOException)
                {
                    // wait for file to be freed
                    Thread.Sleep(1000);
                }
                catch (InvalidDataException)
                {
                    LOG.Error("Could not open " + fileName + ", deleting and trying again");
                    ConfigUtil.RemoveFileIfExists(fileName);
                }
            }

            return(result);
        }
Beispiel #2
0
        public static void Reset()
        {
            if (ConfigUtil.Debug)
            {
                if (Output != null)
                {
                    Output.Close();
                }

                ConfigUtil.RemoveFileIfExists(ConfigUtil.LogsDir + UNPROCESSED_LINES_FILE);
                Output = File.CreateText(ConfigUtil.LogsDir + UNPROCESSED_LINES_FILE);
            }
        }