Exemplo n.º 1
0
        /// <summary>
        /// Creates a new temporary file with a default name
        /// </summary>
        /// <param name="createFile">Indicates if the temporary file should be created</param>
        public TempFile(bool createFile)
        {
            if (createFile)
            {
                // Get the temp path and create the file
                TempPath = Path.GetTempFileName();

                // Get the file info
                var info = TempPath.GetFileInfo();

                // Set the attribute to temporary
                info.Attributes |= FileAttributes.Temporary;
            }
            else
            {
                // Set the temp path
                TempPath = GetTempFilePath(new FileExtension(".tmp"));
            }

            RL.Logger?.LogDebugSource($"A new temp file has been created under {TempPath}");
        }