Beispiel #1
0
        public static bool TempFileCreateOrDelete(string baseFullPath, string tmpFileName, out string tempFilePath)
        {
            if (string.IsNullOrEmpty(baseFullPath) || string.IsNullOrEmpty(tmpFileName))
            {
                Output.OutputMessage(ParserText.ERR_EMPTY_STR);
                tempFilePath = null;

                return(false);
            }

            string pathResult = GetFullPathTempFile(baseFullPath, tmpFileName);

            if (pathResult == null)
            {
                Output.OutputMessage(ParserText.ERR_TEMP_PATH_NOT_CORRECT);
                tempFilePath = null;

                return(false);
            }

            try
            {
                tempFilePath = pathResult;

                if (!File.Exists(pathResult))
                {
                    File.Create(pathResult);
                    FileOperator.SetAttributes(pathResult);
                    return(true);
                }

                FileOperator.SetAttributes(pathResult);
                File.Delete(pathResult);

                return(false);
            }
            catch (Exception e)
            {
                e.Data.Add("File path", pathResult);
                e.Data.Add("File operating", "Create temp file");

                throw new Exception(e.Message, e);
            }
        }
Beispiel #2
0
 public FileOperator(FileOperator op)
     : this(op._fileBasePath, op._fileResultsPath)
 {
 }