Exemple #1
0
 /// <summary>
 /// Initializes the handle for create file.
 /// </summary>
 /// <owner>Aleksey Beletsky</owner>
 /// <param name="fileName">The file name.</param>
 private void InitializeHandleForCreateFile(string fileName)
 {
     this.handle = FileSizeGetter.CreateFile(
         fileName,
         (uint)FileAccess.Read,
         (uint)FileShare.Read,
         IntPtr.Zero,
         (uint)FileMode.Open,
         (uint)FileAttributes.ReadOnly,
         IntPtr.Zero);
 }
Exemple #2
0
        /// <summary>
        /// Processes the specified file.
        /// </summary>
        /// <owner>Aleksey Beletsky</owner>
        /// <param name="fileName">The filename.</param>
        public void ProcessFile(string fileName)
        {
            if (string.IsNullOrWhiteSpace(fileName))
            {
                throw new ArgumentNullException(nameof(fileName));
            }

            this.InitializeHandleForCreateFile(fileName);
            long fileSize;

            FileSizeGetter.GetFileSizeEx(this.handle, out fileSize);
            this.sizePerFiles.Add(new Tuple <string, long>(fileName, fileSize));
        }
Exemple #3
0
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources.
        /// </summary>
        /// <owner>Aleksey Beletsky</owner>
        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c>
        /// to release only unmanaged resources.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (this.disposed)
            {
                return;
            }

            if (disposing)
            {
                this.sizePerFiles = null;
            }

            FileSizeGetter.CloseHandle(this.handle);
            this.handle = IntPtr.Zero;

            this.disposed = true;
        }