CK.Core.FileUtil.CreateAndOpenUniqueTimedFile C# (CSharp) Method

CreateAndOpenUniqueTimedFile() public static method

Creates and opens a new necessarily unique file in a directory that must exist. The file name is based on a DateTime, with an eventual uniquifier if a file already exists with the same name. You can use FileStream.Name to obtain the file name.
public static CreateAndOpenUniqueTimedFile ( string pathPrefix, string fileSuffix, System.DateTime time, FileAccess access, FileShare share, int bufferSize, FileOptions options, int maxTryBeforeGuid = 512 ) : FileStream
pathPrefix string The path prefix. Must not be null. Must be a valid path and may ends with a prefix for the file name itself.
fileSuffix string Suffix for the file name. Must not be null. Typically an extension (like ".txt").
time System.DateTime The time that will be used to create the file name. It must be an UTC time.
access FileAccess /// A constant that determines how the file can be accessed by the FileStream object. /// It can only be or (when set to a is thrown). /// This sets the CanRead and CanWrite properties of the FileStream object. /// CanSeek is true if path specifies a disk file. ///
share FileShare /// A constant that determines how the file will be shared by processes. ///
bufferSize int /// A positive Int32 value greater than 0 indicating the buffer size. For bufferSize values between one and eight, the actual buffer size is set to eight bytes. ///
options FileOptions Specifies additional file options.
maxTryBeforeGuid int /// Maximum value for short hexadecimal uniquifier before using a base 64 guid suffix. Must greater than 0.
return System.IO.FileStream
        public static FileStream CreateAndOpenUniqueTimedFile( string pathPrefix, string fileSuffix, DateTime time, FileAccess access, FileShare share, int bufferSize, FileOptions options, int maxTryBeforeGuid = 512 )
        {
            if( access == FileAccess.Read ) throw new ArgumentException( Impl.CoreResources.FileUtilNoReadOnlyWhenCreateFile, "access" );
            FileStream f = null;
            FindUniqueTimedFile( pathPrefix, fileSuffix, time, maxTryBeforeGuid, p => TryCreateNew( p, access, share, bufferSize, options, out f ) );
            return f;
        }