From 3097d2c1e1decdc52e49f1a7c8cf4f3edd9be2a5 Mon Sep 17 00:00:00 2001 From: josesimoes Date: Thu, 11 Apr 2024 16:34:02 +0100 Subject: [PATCH] Remove duplicated namespace --- System.IO.FileSystem/FileSystemInfo.cs | 151 ++++++++++++------------- 1 file changed, 74 insertions(+), 77 deletions(-) diff --git a/System.IO.FileSystem/FileSystemInfo.cs b/System.IO.FileSystem/FileSystemInfo.cs index 33c7c63..ea805bd 100644 --- a/System.IO.FileSystem/FileSystemInfo.cs +++ b/System.IO.FileSystem/FileSystemInfo.cs @@ -9,108 +9,105 @@ namespace System.IO { - namespace System.IO + /// + /// Provides the base class for both and objects. + /// + public abstract class FileSystemInfo : MarshalByRefObject { + internal NativeFileInfo _nativeFileInfo; + + // fully qualified path of the directory + internal string _fullPath; + /// - /// Provides the base class for both and objects. + /// Gets or sets the attributes for the current file or directory. /// - public abstract class FileSystemInfo : MarshalByRefObject + public FileAttributes Attributes { - internal NativeFileInfo _nativeFileInfo; - - // fully qualified path of the directory - internal string _fullPath; - - /// - /// Gets or sets the attributes for the current file or directory. - /// - public FileAttributes Attributes + get { - get - { - RefreshIfNull(); + RefreshIfNull(); - return (FileAttributes)_nativeFileInfo.Attributes; - } + return (FileAttributes)_nativeFileInfo.Attributes; } + } - /// - /// Gets the full path of the directory or file. - /// - public virtual string FullName + /// + /// Gets the full path of the directory or file. + /// + public virtual string FullName + { + get { - get - { - return _fullPath; - } + return _fullPath; } + } - /// - /// Gets the extension part of the file name, including the leading dot . even if it is the entire file name, or an empty string if no extension is present. - /// - /// A string containing the FileSystemInfo extension. - public string Extension + /// + /// Gets the extension part of the file name, including the leading dot . even if it is the entire file name, or an empty string if no extension is present. + /// + /// A string containing the FileSystemInfo extension. + public string Extension + { + get { - get - { - return Path.GetExtension(FullName); - } + return Path.GetExtension(FullName); } + } - /// - /// Gets a value indicating whether the file or directory exists. - /// - public abstract bool Exists - { - get; - } + /// + /// Gets a value indicating whether the file or directory exists. + /// + public abstract bool Exists + { + get; + } - /// - /// Gets the name of the file. - /// - public abstract string Name - { - get; - } + /// + /// Gets the name of the file. + /// + public abstract string Name + { + get; + } - /// - /// Deletes a file or directory. - /// - public abstract void Delete(); + /// + /// Deletes a file or directory. + /// + public abstract void Delete(); - /// - /// Refreshes the state of the object. - /// - /// A device such as a disk drive is not ready. - public void Refresh() + /// + /// Refreshes the state of the object. + /// + /// A device such as a disk drive is not ready. + public void Refresh() + { + object record = FileSystemManager.AddToOpenListForRead(_fullPath); + + try { - object record = FileSystemManager.AddToOpenListForRead(_fullPath); + _nativeFileInfo = NativeFindFile.GetFileInfo(_fullPath); - try + if (_nativeFileInfo == null) { - _nativeFileInfo = NativeFindFile.GetFileInfo(_fullPath); + IOException.IOExceptionErrorCode errorCode = (this is FileInfo) ? IOException.IOExceptionErrorCode.FileNotFound : IOException.IOExceptionErrorCode.DirectoryNotFound; - if (_nativeFileInfo == null) - { - IOException.IOExceptionErrorCode errorCode = (this is FileInfo) ? IOException.IOExceptionErrorCode.FileNotFound : IOException.IOExceptionErrorCode.DirectoryNotFound; - - throw new IOException( - string.Empty, - (int)errorCode); - } - } - finally - { - FileSystemManager.RemoveFromOpenList(record); + throw new IOException( + string.Empty, + (int)errorCode); } } + finally + { + FileSystemManager.RemoveFromOpenList(record); + } + } - internal void RefreshIfNull() + internal void RefreshIfNull() + { + if (_nativeFileInfo == null) { - if (_nativeFileInfo == null) - { - Refresh(); - } + Refresh(); } } }