FileInfoExtensions Class

Contains custom extension methods to use with FileInfo type.

Definition

Namespace: DevCase.Extensions.FileInfoExtensions
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[HideModuleNameAttribute]
public sealed class FileInfoExtensions
Inheritance
Object    FileInfoExtensions

Methods

ContainsFilename Determines whether the source IEnumerableT contains an element with the specified file name.
CopyTo(FileInfo, DirectoryInfo) Copies the source file to the specified directory.

If the target file already exists, an IOException is thrown.

CopyTo(FileInfo, DirectoryInfo, Boolean) Copies the source file to the specified directory.
CreateAllDirectories(FileInfo) Creates all directories and subdirectories in the path.
CreateAllDirectories(FileInfo, DirectorySecurity) Creates all directories and subdirectories in the path.
CreateZipFile(FileInfo) Creates a zip archive from the specified file, using the source filename to create the zip file, with Optimal compression level.
CreateZipFile(FileInfo, CompressionLevel) Creates a zip archive from the specified file, using the source filename to create the zip file, with the specified compression level.
CreateZipFile(FileInfo, FileInfo) Creates a zip archive from the specified file, using the specified filepath to create the zip file, with Optimal compression level.
CreateZipFile(FileInfo, String) Creates a zip archive from the specified file, using the specified filepath to create the zip file, with Optimal compression level.
CreateZipFile(FileInfo, FileInfo, CompressionLevel) Creates a zip archive from the specified file, using the specified filepath to create the zip file, with the specified compression level.
CreateZipFile(FileInfo, String, CompressionLevel) Creates a zip archive from the specified file, using the specified filepath to create the zip file, with the specified compression level.
Equals Determines whether the specified object is equal to the current object.
(Inherited from Object)
ExtractIcon Extracts the icon associated for the source file.

Note: the maximum size of the returned icon only can be 32x32.

ForceDelete Forces the permanent deletion of the specified file by removing the read-only attribute and deleting it.
ForceRecycle Forces the recycling of the specified file by removing the read-only attribute and sending it to the recycle bin.
GetAlternateDataStream Gets the data of a specific alternate data stream (ADS) from the specified file.
GetAlternateDataStreams(FileInfo) Gets all the NTFS alternate data streams (ADS) linked to the specified file.
GetAlternateDataStreams(FileInfo, FindStreamType) Gets all the NTFS alternate data streams (ADS) that matches the specified stream type linked to the specified file.
GetHashCode Serves as the default hash function.
(Inherited from Object)
GetNameWithoutExtension Gets the name of the file, without the extension.
GetType Gets the Type of the current instance.
(Inherited from Object)
HasExtension Determines whether the path includes a file extension.
HasRights Determines whether the source file contains the specified user-rights.
IsAccesible Determines whether the source file is accesible in the context of reading or writting to the file.
IsHidden Determines whether the source file is hidden, i.e., it has the Hidden attribute.
IsSystem Determines whether the source file is a system file, i.e., it has the System attribute.
Lock(FileInfo) Locks read/write access to the specified file for other applications (during the lifetime of the current application).

To unlock the file, just dispose the returned FileStream object.

Lock(FileInfo, FileShare) Locks read/write access to the specified file for other applications (during the lifetime of the current application).

To unlock the file, just dispose the returned FileStream object.

MoveTo(FileInfo, DirectoryInfo) Moves the source file to the specified directory.

If the target file already exists, an IOException is thrown.

MoveTo(FileInfo, DirectoryInfo, Boolean) Moves the source file to the specified directory.
OpenInExplorer Opens the specified file in Explorer.
OrderByCreationTime Sorts the elements of the source IEnumerableT by their CreationTime property.
OrderByFileSize Sorts the elements of the source IEnumerableT by their Length property.
OrderByLastAccessTime Sorts the elements of the source IEnumerableT by their LastAccessTime property.
OrderByLastWriteTime Sorts the elements of the source IEnumerableT by their LastWriteTime property.
OrderByNameAlphabetical Sorts the elements of the source IEnumerableT by their Name property using alphabetical order.

https://en.wikipedia.org/wiki/Alphabetical_order

OrderByNameNatural Sorts the elements of the source IEnumerableT by their Name property using natural order.

https://en.wikipedia.org/wiki/Natural_sort_order

Recycle Sends the source file to the Recycle Bin.
Rename(FileInfo, String) Renames the name of the file.
Rename(FileInfo, String, String) Renames the name of the file.
RenameExtension Changes the extension of the file.
SetAlternateDataStream Create or modify an alternate data stream (ADS) for the specified file, and sets the stream data.
SetRights Sets the user-rights of the source file.
ToShellItem Converts the source FileInfo to IShellItem.
ToString Returns a string that represents the current object.
(Inherited from Object)

Extension Methods

CanConvertTo Determines whether the source object can be converted to the specified target type.
(Defined by ObjectExtensions)
CanConvertToT Determines whether the source object can be converted to the specified target type.
(Defined by ObjectExtensions)
ConvertToT Converts an object to the specified target type.

If the conversion fails, an exception is thrown.
(Defined by ObjectExtensions)

ConvertToT Converts an object to the specified target type.

If the conversion fails, returns the specified default value.
(Defined by ObjectExtensions)

IsDisposable Determines whether the specified object is a disposable type (i.e., it implements IDisposable interface).
(Defined by ObjectExtensions)
Speak Speaks the string representation of the source object by using the operating system integrated text-to-speech synthesizer.
(Defined by ObjectExtensions)
Speak Speaks the string representation of the source object by using the operating system integrated text-to-speech synthesizer.
(Defined by ObjectExtensions)
ThrowIfNullTException Throws the specified exception if the source object is null.
(Defined by ObjectExtensions)

See Also