diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/FileSystemProxy.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/FileSystemProxy.vb
index 40ef540cbf5..46387be5f97 100644
--- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/FileSystemProxy.vb
+++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/FileSystemProxy.vb
@@ -3,13 +3,17 @@
Imports System.Collections.ObjectModel
Imports System.ComponentModel
+Imports System.Security
Imports System.Text
Imports Microsoft.VisualBasic.FileIO
Namespace Microsoft.VisualBasic.MyServices
'''
- ''' An extremely thin wrapper around to expose the type through .
+ ''' This class represents the on a computer.
+ ''' It allows browsing the existing drives, special directories;
+ ''' and also contains some commonly use methods for IO tasks.
+ ''' It exposes them through the
'''
Public Class FileSystemProxy
@@ -22,6 +26,10 @@ Namespace Microsoft.VisualBasic.MyServices
Friend Sub New()
End Sub
+ '''
+ ''' Gets or sets the current working directory.
+ '''
+ ''' A String containing the path to the directory.
Public Property CurrentDirectory() As String
Get
Return FileIO.FileSystem.CurrentDirectory
@@ -31,12 +39,22 @@ Namespace Microsoft.VisualBasic.MyServices
End Set
End Property
+ '''
+ ''' Returns the names of all available drives on the computer.
+ '''
+ ''' A containing all the current drive names.
Public ReadOnly Property Drives() As ReadOnlyCollection(Of IO.DriveInfo)
Get
Return FileIO.FileSystem.Drives
End Get
End Property
+ '''
+ ''' Returns an instance of
+ ''' specific to the current user (My Documents, My Music ...) and those specific
+ ''' to the current Application that a developer expects to be able to find quickly.
+ '''
+ ''' a cached instance of
Public ReadOnly Property SpecialDirectories() As SpecialDirectoriesProxy
Get
If _specialDirectoriesProxy Is Nothing Then
@@ -46,22 +64,154 @@ Namespace Microsoft.VisualBasic.MyServices
End Get
End Property
+ '''
+ ''' Combines two path strings by adding a path separator.
+ '''
+ ''' The first part of the path.
+ ''' The second part of the path, must be a relative path.
+ ''' A String contains the combined path.
+ '''
+ ''' or are malformed paths.
+ '''
Public Function CombinePath(baseDirectory As String, relativePath As String) As String
Return FileIO.FileSystem.CombinePath(baseDirectory, relativePath)
End Function
+ '''
+ ''' Copy an existing directory to a new directory,
+ ''' throwing exception if there are existing files with the same name.
+ '''
+ ''' The path to the source directory, can be relative or absolute.
+ '''
+ ''' The path to the target directory, can be relative or absolute.
+ ''' Parent directory will always be created.
+ '''
+ '''
+ ''' The path is not valid for one of the following reasons: it is a zero-length string;
+ ''' it contains only white space; it contains invalid characters;
+ ''' or it is a device path (starts with \.\).
+ '''
+ '''
+ ''' or
+ ''' is or an empty string.
+ '''
+ ''' The source directory does not exist.
+ ''' The source path and target path are the same.
+ ''' The path exceeds the system-defined maximum length.
+ ''' The operation is cyclic.
+ ''' A folder name in the path contains a colon (:) or is in an invalid format.
+ ''' The user lacks necessary permissions to view the path.
+ ''' A destination file exists but cannot be accessed.
Public Sub CopyDirectory(sourceDirectoryName As String, destinationDirectoryName As String)
FileIO.FileSystem.CopyDirectory(sourceDirectoryName, destinationDirectoryName)
End Sub
+ '''
+ ''' Copy an existing directory to a new directory,
+ ''' overwriting existing files with the same name if specified.
+ '''
+ ''' The path to the source directory, can be relative or absolute.
+ '''
+ ''' The path to the target directory, can be relative or absolute.
+ ''' Parent directory will always be created.
+ '''
+ '''
+ ''' to overwrite existing files with the same name.
+ ''' Otherwise .
+ '''
+ '''
+ ''' The path is not valid for one of the following reasons: it is a zero-length string;
+ ''' it contains only white space; it contains invalid characters;
+ ''' or it is a device path (starts with \.\).
+ '''
+ '''
+ ''' or
+ ''' is or an empty string.
+ '''
+ ''' The source directory does not exist.
+ ''' The source path and target path are the same.
+ ''' The path exceeds the system-defined maximum length.
+ ''' The operation is cyclic.
+ ''' A folder name in the path contains a colon (:) or is in an invalid format.
+ ''' The user lacks necessary permissions to view the path.
+ ''' A destination file exists but cannot be accessed.
Public Sub CopyDirectory(sourceDirectoryName As String, destinationDirectoryName As String, overwrite As Boolean)
FileIO.FileSystem.CopyDirectory(sourceDirectoryName, destinationDirectoryName, overwrite)
End Sub
+ '''
+ ''' Copy an existing directory to a new directory,
+ ''' displaying and confirmation dialogs if specified,
+ ''' throwing if user cancels the operation
+ ''' (only applies if displaying ProgressDialog and confirmation dialogs).
+ '''
+ ''' The path to the source directory, can be relative or absolute.
+ '''
+ ''' The path to the target directory, can be relative or absolute.
+ ''' Parent directory will always be created.
+ '''
+ '''
+ ''' Specifies whether To visually track the operation's progress.
+ ''' Default is .
+ '''
+ '''
+ ''' The path is not valid for one of the following reasons: it is a zero-length string;
+ ''' it contains only white space; it contains invalid characters;
+ ''' or it is a device path (starts with \.\).
+ '''
+ '''
+ ''' or
+ ''' is or an empty string.
+ '''
+ ''' The source directory does not exist.
+ ''' The source path and target path are the same.
+ ''' The path exceeds the system-defined maximum length.
+ ''' The operation is cyclic.
+ ''' A folder name in the path contains a colon (:) or is in an invalid format.
+ ''' The user lacks necessary permissions to view the path.
+ ''' A destination file exists but cannot be accessed.
+ ''' The user cancels the operation or the directory cannot be copied.
Public Sub CopyDirectory(sourceDirectoryName As String, destinationDirectoryName As String, showUI As UIOption)
FileIO.FileSystem.CopyDirectory(sourceDirectoryName, destinationDirectoryName, showUI)
End Sub
+ '''
+ ''' Copy an existing directory to a new directory,
+ ''' displaying and confirmation messages if specified,
+ ''' throwing exception if user cancels the operation if specified.
+ ''' (only applies if displaying ProgressDialog and confirmation messages).
+ '''
+ ''' The path to the source directory, can be relative or absolute.
+ '''
+ ''' The path to the target directory, can be relative or absolute.
+ ''' Parent directory will always be created.
+ '''
+ '''
+ ''' Specifies whether To visually track the operation's progress.
+ ''' Default is .
+ '''
+ '''
+ ''' Specifies whether to throw an if the user clicks Cancel.>.
+ '''
+ '''
+ ''' The path is not valid for one of the following reasons: it is a zero-length string;
+ ''' it contains only white space; it contains invalid characters;
+ ''' or it is a device path (starts with \.\).
+ '''
+ '''
+ ''' or
+ ''' is or an empty string.
+ '''
+ ''' The source directory does not exist.
+ ''' The source path and target path are the same.
+ ''' The path exceeds the system-defined maximum length.
+ ''' The operation is cyclic.
+ ''' A folder name in the path contains a colon (:) or is in an invalid format.
+ ''' The user lacks necessary permissions to view the path.
+ ''' A destination file exists but cannot be accessed.
+ '''
+ ''' The user cancelled the operation and is set to .
+ '''
Public Sub CopyDirectory(
sourceDirectoryName As String,
destinationDirectoryName As String,
@@ -71,38 +221,260 @@ Namespace Microsoft.VisualBasic.MyServices
FileIO.FileSystem.CopyDirectory(sourceDirectoryName, destinationDirectoryName, showUI, onUserCancel)
End Sub
+ '''
+ ''' Copy an existing file to a new file. Overwriting a file of the same name is not allowed.
+ '''
+ ''' The path to the source file, can be relative or absolute.
+ '''
+ ''' The path to the destination file, can be relative or absolute.
+ ''' Parent directory will always be created.
+ '''
+ '''
+ ''' contains path information.
+ '''
+ '''
+ ''' or is Nothing or an empty string.
+ '''
+ ''' The source file is not valid or does not exist.
+ ''' A file in the target directory with the same name is in use.
+ '''
+ ''' A file or directory name in the path contains a colon (:) or is in an invalid format.
+ '''
+ ''' The path exceeds the system-defined maximum length.
+ ''' The user does not have required permission.
+ ''' The user lacks necessary permissions to view the path.
Public Sub CopyFile(sourceFileName As String, destinationFileName As String)
FileIO.FileSystem.CopyFile(sourceFileName, destinationFileName)
End Sub
+ '''
+ ''' Copy an existing file to a new file. Overwriting a file of the same name if specified.
+ '''
+ ''' The path to the source file, can be relative or absolute.
+ '''
+ ''' The path to the destination file, can be relative or absolute.
+ ''' Parent directory will always be created.
+ '''
+ '''
+ ''' to overwrite existing file with the same name.
+ ''' Otherwise .
+ '''
+ '''
+ ''' contains path information.
+ '''
+ '''
+ ''' or is Nothing or an empty string.
+ '''
+ ''' The source file is not valid or does not exist.
+ ''' A file in the target directory with the same name is in use.
+ '''
+ ''' A file or directory name in the path contains a colon (:) or is in an invalid format.
+ '''
+ ''' The path exceeds the system-defined maximum length.
+ ''' The user does not have required permission.
+ ''' The user lacks necessary permissions to view the path.
Public Sub CopyFile(sourceFileName As String, destinationFileName As String, overwrite As Boolean)
FileIO.FileSystem.CopyFile(sourceFileName, destinationFileName, overwrite)
End Sub
+ '''
+ ''' Copy an existing file to a new file,
+ ''' displaying and confirmation messages if specified,
+ ''' will throw exception if user cancels the operation.
+ '''
+ ''' The path to the source file, can be relative or absolute.
+ '''
+ ''' The path to the destination file, can be relative or absolute.
+ ''' Parent directory will always be created.
+ '''
+ '''
+ ''' Specifies whether To visually track the operation's progress.
+ ''' Default is .
+ '''
+ '''
+ ''' contains path information.
+ '''
+ '''
+ ''' or is Nothing or an empty string.
+ '''
+ ''' The source file is not valid or does not exist.
+ ''' A file in the target directory with the same name is in use.
+ '''
+ ''' A file or directory name in the path contains a colon (:) or is in an invalid format.
+ '''
+ ''' The path exceeds the system-defined maximum length.
+ ''' The user does not have required permission.
+ ''' The user lacks necessary permissions to view the path.
Public Sub CopyFile(sourceFileName As String, destinationFileName As String, showUI As UIOption)
FileIO.FileSystem.CopyFile(sourceFileName, destinationFileName, showUI)
End Sub
+ '''
+ ''' Copy an existing file to a new file,
+ ''' displaying and confirmation messages if specified,
+ ''' will throw if user cancels the operation if specified.
+ '''
+ ''' The path to the source file, can be relative or absolute.
+ '''
+ ''' The path to the destination file, can be relative or absolute.
+ ''' Parent directory will always be created.
+ '''
+ '''
+ ''' Specifies whether To visually track the operation's progress.
+ ''' Default is .
+ '''
+ '''
+ ''' Specifies whether to throw an if the user clicks Cancel.>.
+ '''
+ '''
+ ''' contains path information.
+ '''
+ '''
+ ''' or is Nothing or an empty string.
+ '''
+ ''' The source file is not valid or does not exist.
+ ''' A file in the target directory with the same name is in use.
+ '''
+ ''' A file or directory name in the path contains a colon (:) or is in an invalid format.
+ '''
+ ''' The path exceeds the system-defined maximum length.
+ ''' The user does not have required permission.
+ ''' The user lacks necessary permissions to view the path.
+ '''
+ ''' The user cancelled the operation and is set to .
+ '''
Public Sub CopyFile(
sourceFileName As String,
destinationFileName As String,
showUI As UIOption,
onUserCancel As UICancelOption)
+
FileIO.FileSystem.CopyFile(sourceFileName, destinationFileName, showUI, onUserCancel)
End Sub
+ '''
+ ''' Creates a directory from the given path (including all parent directories).
+ '''
+ ''' The path to create the directory at.
+ '''
+ ''' The directory name is malformed. For example, it contains illegal characters or is only white space.
+ '''
+ '''
+ ''' is or an empty string.
+ '''
+ ''' The directory name is too long.
+ '''
+ ''' The directory name is only a colon (:).
+ '''
+ ''' The parent directory of the directory to be created is read-only.
+ ''' The user does not have permission to create the directory.
Public Sub CreateDirectory(directory As String)
FileIO.FileSystem.CreateDirectory(directory)
End Sub
- Public Sub DeleteDirectory(directory As String, showUI As UIOption, recycle As RecycleOption)
- FileIO.FileSystem.DeleteDirectory(directory, showUI, recycle)
- End Sub
-
+ '''
+ ''' Deletes the given directory, with options to recursively delete.
+ '''
+ ''' The path to the directory.
+ '''
+ ''' to delete everything.
+ '''
+ ''' to throw if the directory is not empty.
+ '''
+ '''
+ '''
+ ''' The path is a zero-length string, is malformed, contains only white space,
+ ''' or contains invalid characters (including wildcard characters).
+ ''' The path is a device path (starts with \.\).
+ '''
+ '''
+ ''' is or an empty string.
+ '''
+ ''' The directory does not exist or is a file.
+ ''' A file in the directory or subdirectory is in use.
+ '''
+ ''' The directory name is only a colon (:).
+ '''
+ ''' The path exceeds the system-defined maximum length.
+ ''' The user does not have permission to create the directory.
+ ''' The user lacks necessary permissions to view the path.
Public Sub DeleteDirectory(directory As String, onDirectoryNotEmpty As DeleteDirectoryOption)
FileIO.FileSystem.DeleteDirectory(directory, onDirectoryNotEmpty)
End Sub
+ '''
+ ''' Deletes the given directory,
+ ''' with UI options to show , and
+ ''' throwing if user cancels.
+ ''' recycle options to or ,
+ '''
+ ''' The path to the directory.
+ '''
+ ''' Specifies whether To visually track the operation's progress.
+ ''' Default is .
+ '''
+ '''
+ ''' Specifies whether or not the deleted file should be sent to the Recycle Bin.
+ ''' Default is
+ '''
+ '''
+ ''' The path is a zero-length string, is malformed, contains only white space,
+ ''' or contains invalid characters (including wildcard characters).
+ ''' The path is a device path (starts with \.\).
+ '''
+ '''
+ ''' is or an empty string.
+ '''
+ ''' The directory does not exist or is a file.
+ ''' The source is a root directory or The source path and the target path are the same.
+ '''
+ ''' The directory name is only a colon (:).
+ '''
+ ''' The path exceeds the system-defined maximum length.
+ ''' The user does not have permission to create the directory.
+ ''' The user lacks necessary permissions to view the path.
+ ''' The user cancels the operation or the directory cannot be deleted.
+ Public Sub DeleteDirectory(directory As String, showUI As UIOption, recycle As RecycleOption)
+ FileIO.FileSystem.DeleteDirectory(directory, showUI, recycle)
+ End Sub
+
+ '''
+ ''' Deletes the given directory,
+ ''' with UI options to show ,
+ ''' recycle options , ,
+ ''' and UI cancel options to , or .
+ '''
+ ''' The path to the directory.
+ '''
+ ''' Specifies whether To visually track the operation's progress.
+ ''' Default is .
+ '''
+ '''
+ ''' Specifies whether or not the deleted file should be sent to the Recycle Bin.
+ ''' Default is
+ '''
+ '''
+ ''' Specifies whether to throw an if the user clicks Cancel.>.
+ '''
+ '''
+ ''' The path is a zero-length string, is malformed, contains only white space,
+ ''' or contains invalid characters (including wildcard characters).
+ ''' The path is a device path (starts with \.\).
+ '''
+ '''
+ ''' is or an empty string.
+ '''
+ ''' The directory does not exist or is a file.
+ ''' A file in the directory or subdirectory is in use.
+ '''
+ ''' The directory name is only a colon (:).
+ '''
+ ''' The path exceeds the system-defined maximum length.
+ ''' The user does not have permission to create the directory.
+ ''' The user lacks necessary permissions to view the path.
+ '''
+ ''' The user cancelled the operation and is set to .
+ '''
Public Sub DeleteDirectory(
directory As String,
showUI As UIOption,
@@ -112,10 +484,63 @@ Namespace Microsoft.VisualBasic.MyServices
FileIO.FileSystem.DeleteDirectory(directory, showUI, recycle, onUserCancel)
End Sub
+ '''
+ ''' Delete the given file.
+ '''
+ ''' The path to the file.
+ '''
+ ''' The path Is Not valid For one Of the following reasons:
+ ''' It Is a zero-length string;
+ ''' It contains only white space;
+ ''' It contains invalid characters;
+ ''' It has a trailing slash where a file must be specified;
+ ''' It Is a device path (starts with \.\).
+ '''
+ ''' File is or an empty string.
+ ''' The path exceeds the system-defined maximum length.
+ ''' A file or directory name in the path contains a colon (:) or is in an invalid format.
+ ''' The file is in use.
+ ''' The user lacks necessary permissions to view the path.
+ ''' The file does not exist.
+ ''' The user does not have permission to delete the file or the file is read-only.
Public Sub DeleteFile(file As String)
FileIO.FileSystem.DeleteFile(file)
End Sub
+ '''
+ ''' Delete the given file, with options to show , delete to recycle bin,
+ ''' and whether to throw exception if user cancels.
+ '''
+ ''' The path to the file.
+ '''
+ ''' Specifies whether To visually track the operation's progress.
+ ''' Default is .
+ '''
+ '''
+ ''' Specifies whether or not the deleted file should be sent to the Recycle Bin.
+ ''' Default is
+ '''
+ '''
+ ''' Specifies whether to throw an if the user clicks Cancel.>.
+ '''
+ '''
+ ''' The path Is Not valid For one Of the following reasons:
+ ''' It Is a zero-length string;
+ ''' It contains only white space;
+ ''' It contains invalid characters;
+ ''' It has a trailing slash where a file must be specified;
+ ''' It Is a device path (starts with \.\).
+ '''
+ ''' File is or an empty string.
+ ''' The path exceeds the system-defined maximum length.
+ ''' A file or directory name in the path contains a colon (:) or is in an invalid format.
+ ''' The file is in use.
+ ''' The user lacks necessary permissions to view the path.
+ ''' The file does not exist.
+ ''' The user does not have permission to delete the file or the file is read-only.
+ '''
+ ''' The user cancelled the operation and is set to .
+ '''
Public Sub DeleteFile(
file As String,
showUI As UIOption,
@@ -125,24 +550,126 @@ Namespace Microsoft.VisualBasic.MyServices
FileIO.FileSystem.DeleteFile(file, showUI, recycle, onUserCancel)
End Sub
+ '''
+ ''' Delete the given file, with options to show , delete to recycle bin.
+ '''
+ ''' The path to the file.
+ '''
+ ''' Specifies whether To visually track the operation's progress.
+ ''' Default is .
+ '''
+ '''
+ ''' Specifies whether or not the deleted file should be sent to the Recycle Bin.
+ ''' Default is
+ '''
+ '''
+ ''' The path Is Not valid For one Of the following reasons:
+ ''' It Is a zero-length string;
+ ''' It contains only white space;
+ ''' It contains invalid characters;
+ ''' It has a trailing slash where a file must be specified;
+ ''' It Is a device path (starts with \.\).
+ '''
+ ''' File is or an empty string.
+ ''' The path exceeds the system-defined maximum length.
+ ''' A file or directory name in the path contains a colon (:) or is in an invalid format.
+ ''' The file is in use.
+ ''' The user lacks necessary permissions to view the path.
+ ''' The file does not exist.
+ ''' The user does not have permission to delete the file or the file is read-only.
Public Sub DeleteFile(file As String, showUI As UIOption, recycle As RecycleOption)
FileIO.FileSystem.DeleteFile(file, showUI, recycle)
End Sub
+ '''
+ ''' Determines whether the given path refers to an existing directory on disk.
+ '''
+ ''' The path to verify.
+ '''
+ ''' if DirectoryPath refers to an existing directory.
+ ''' Otherwise, .
+ '''
Public Function DirectoryExists(directory As String) As Boolean
Return FileIO.FileSystem.DirectoryExists(directory)
End Function
+ '''
+ ''' Determines whether the given path refers to an existing file on disk.
+ '''
+ ''' The path to verify.
+ '''
+ ''' if FilePath refers to an existing file on disk.
+ ''' Otherwise, .
+ '''
Public Function FileExists(file As String) As Boolean
Return FileIO.FileSystem.FileExists(file)
End Function
- Public Function FindInFiles(directory As String,
- containsText As String, ignoreCase As Boolean, searchType As SearchOption) As ReadOnlyCollection(Of String)
+ '''
+ ''' Find files in the given folder that contain the given text.
+ '''
+ ''' The folder path to start from.
+ ''' The text to be found in file.
+ '''
+ ''' to ignore case.
+ ''' Otherwise, .
+ '''
+ '''
+ ''' to find recursively,
+ ''' otherwise, .
+ '''
+ ''' A string array containing the files that match the search condition.
+ ''' File is or an empty string.
+ ''' The does not exist.
+ ''' The specified points to an existing file.
+ ''' The path exceeds the system-defined maximum length.
+ '''
+ ''' A file or directory name in the path contains a colon (:) or
+ ''' is in an invalid format.
+ '''
+ ''' The user lacks necessary permissions to view the path.
+ ''' The user lacks necessary permissions.
+ Public Function FindInFiles(
+ directory As String,
+ containsText As String,
+ ignoreCase As Boolean,
+ searchType As SearchOption) As ReadOnlyCollection(Of String)
Return FileIO.FileSystem.FindInFiles(directory, containsText, ignoreCase, searchType)
End Function
+ '''
+ ''' Find files in the given folder that contain the given text.
+ '''
+ ''' The folder path to start from.
+ ''' The text to be found in file.
+ '''
+ ''' to ignore case.
+ ''' Otherwise, .
+ '''
+ '''
+ ''' to find recursively,
+ ''' otherwise, .
+ '''
+ ''' The search patterns to use for the file name ("*.*")
+ ''' A string array containing the files that match the search condition.
+ '''
+ ''' is Nothing or an empty string.
+ '''
+ '''
+ ''' The path is not valid for one of the following reasons: it is a zero-length string;
+ ''' it contains only white space; it contains invalid characters; or it is a device path.
+ '''
+ ''' File is or an empty string.
+ ''' The does not exist.
+ ''' The specified points to an existing file.
+ ''' The path exceeds the system-defined maximum length.
+ '''
+ ''' A file or directory name in the path contains a colon (:) or
+ ''' is in an invalid format.
+ '''
+ ''' The user lacks necessary permissions to view the path.
+ ''' The user lacks necessary permissions.
Public Function FindInFiles(
directory As String,
containsText As String,
@@ -153,10 +680,51 @@ Namespace Microsoft.VisualBasic.MyServices
Return FileIO.FileSystem.FindInFiles(directory, containsText, ignoreCase, searchType, fileWildcards)
End Function
+ '''
+ ''' Return the paths of sub directories found directly under a directory.
+ '''
+ ''' The directory to find the sub directories inside.
+ ''' A ReadOnlyCollection(Of String) containing the matched directories' paths.
+ '''
+ ''' The path is not valid for one of the following reasons: it is a zero-length string;
+ ''' it contains only white space; it contains invalid characters;
+ ''' or it is a device path (starts with \.\).
+ '''
+ '''
+ ''' is or an empty string.
+ '''
+ ''' The source directory does not exist.
+ ''' The specified directory points to an existing file.
+ ''' The path exceeds the system-defined maximum length.
+ ''' The operation is cyclic.
+ ''' A file or directory name in the path contains a colon (:) or is in an invalid format.
+ ''' The user lacks necessary permissions to view the path.
+ ''' A destination file exists but cannot be accessed.
Public Function GetDirectories(directory As String) As ReadOnlyCollection(Of String)
Return FileIO.FileSystem.GetDirectories(directory)
End Function
+ '''
+ ''' Return the paths of sub directories found under a directory with the specified name patterns.
+ '''
+ ''' The directory to find the sub directories inside.
+ '''
+ ''' to find recursively,
+ ''' otherwise, .
+ '''
+ ''' The wildcards for the file name, for example "*.bmp", "*.txt"
+ ''' A ReadOnlyCollection(Of String) containing the matched directories' paths.
+ '''
+ ''' The path is not valid for one of the following reasons: it is a zero-length string;
+ ''' it contains only white space; it contains invalid characters;
+ ''' or it is a device path (starts with \.\).
+ '''
+ '''
+ ''' is or an empty string.
+ '''
+ ''' The path exceeds the system-defined maximum length.
+ ''' The directory path contains a colon (:) or is in an invalid format.
+ ''' The user lacks necessary permissions to view the path.
Public Function GetDirectories(
directory As String,
searchType As SearchOption,
@@ -165,22 +733,117 @@ Namespace Microsoft.VisualBasic.MyServices
Return FileIO.FileSystem.GetDirectories(directory, searchType, wildcards)
End Function
+ '''
+ ''' Returns the information object about the specified directory.
+ '''
+ ''' The path to the directory.
+ ''' A DirectoryInfo object containing the information about the specified directory.
+ '''
+ ''' The path is not valid for one of the following reasons: it is a zero-length string;
+ ''' it contains only white space; it contains invalid characters;
+ ''' or it is a device path (starts with \.\).
+ '''
+ '''
+ ''' is or an empty string.
+ '''
+ ''' The path exceeds the system-defined maximum length.
+ ''' The user lacks necessary permissions to view the path.
Public Function GetDirectoryInfo(directory As String) As IO.DirectoryInfo
Return FileIO.FileSystem.GetDirectoryInfo(directory)
End Function
+ '''
+ ''' Return the information about the specified drive.
+ '''
+ ''' The path to the drive.
+ ''' A DriveInfo object containing the information about the specified drive.
+ '''
+ ''' The path is not valid for one of the following reasons: it is a zero-length string;
+ ''' it contains only white space; it contains invalid characters;
+ ''' or it is a device path (starts with \.\).
+ '''
+ '''
+ ''' is or an empty string.
+ '''
+ ''' The path exceeds the system-defined maximum length.
+ ''' The user lacks necessary permissions to view the path.
Public Function GetDriveInfo(drive As String) As IO.DriveInfo
Return FileIO.FileSystem.GetDriveInfo(drive)
End Function
+ '''
+ ''' Returns the information about the specified file.
+ '''
+ ''' The path to the file.
+ ''' A FileInfo object containing the information about the specified file.
+ '''
+ ''' The path name is malformed.
+ ''' For example, it contains invalid characters or is only white space.
+ ''' The file name has a trailing slash mark.
+ '''
+ '''
+ ''' is or an empty string.
+ '''
+ ''' The path contains a colon in the middle of the string.
+ ''' The path exceeds the system-defined maximum length.
+ ''' The user lacks necessary permissions to view the path.
+ ''' The user lacks ACL (access control list) access to the file.
Public Function GetFileInfo(file As String) As IO.FileInfo
Return FileIO.FileSystem.GetFileInfo(file)
End Function
+ '''
+ ''' Return an unordered collection of file paths found directly under a directory.
+ '''
+ ''' The directory to find the files inside.
+ ''' A containing the matched files' paths.
+ '''
+ ''' The path is not valid for one of the following reasons: it is a zero-length string;
+ ''' it contains only white space; it contains invalid characters;
+ ''' or it is a device path (starts with \.\).
+ '''
+ '''
+ ''' is or an empty string.
+ '''
+ ''' The directory to search does not exist
+ ''' The path exceeds the system-defined maximum length.
+ '''
+ ''' A file or directory name in the path contains a colon (:) or
+ ''' is in an invalid format.
+ '''
+ ''' The user lacks necessary permissions to view the path.
+ ''' The user lacks necessary permissions.
Public Function GetFiles(directory As String) As ReadOnlyCollection(Of String)
Return FileIO.FileSystem.GetFiles(directory)
End Function
+ '''
+ ''' Return an unordered collection of file paths found under a directory
+ ''' with the specified name patterns and containing the specified text.
+ '''
+ ''' The directory to find the files inside.
+ '''
+ ''' to find recursively,
+ ''' otherwise, .
+ '''
+ ''' The wildcards for the file name, for example "*.bmp", "*.txt"
+ ''' A ReadOnlyCollection(Of String) containing the matched files' paths.
+ '''
+ ''' The path is not valid for one of the following reasons: it is a zero-length string;
+ ''' it contains only white space; it contains invalid characters;
+ ''' or it is a device path (starts with \.\).
+ '''
+ '''
+ ''' is or an empty string.
+ '''
+ ''' The directory to search does not exist
+ ''' The path exceeds the system-defined maximum length.
+ '''
+ ''' A file or directory name in the path contains a colon (:) or
+ ''' is in an invalid format.
+ '''
+ ''' The user lacks necessary permissions to view the path.
+ ''' The user lacks necessary permissions.
Public Function GetFiles(
directory As String,
searchType As SearchOption,
@@ -189,30 +852,193 @@ Namespace Microsoft.VisualBasic.MyServices
Return FileIO.FileSystem.GetFiles(directory, searchType, wildcards)
End Function
+ '''
+ ''' Return the name (and extension) from the given path string.
+ '''
+ ''' The path string from which to obtain the file name (and extension).
+ ''' A String containing the name of the file or directory.
+ ''' path contains one or more of the invalid characters
+ ''' defined in InvalidPathChars.
Public Function GetName(path As String) As String
Return FileIO.FileSystem.GetName(path)
End Function
+ '''
+ ''' Returns the parent directory's path from a specified path.
+ '''
+ ''' The path to a file or directory, this can be absolute or relative.
+ '''
+ ''' The path to the parent directory of that file or directory
+ ''' (whether absolute or relative depends on the input), or an empty string if Path is a root directory.
+ '''
+ ''' See IO.Path.GetFullPath: If path is an invalid path.
+ '''
+ ''' The path will be normalized (for example: C:\Dir1////\\\Dir2 will become C:\Dir1\Dir2)
+ ''' but will not be resolved (for example: C:\Dir1\Dir2\..\Dir3 WILL NOT become C:\Dir1\Dir3). Use CombinePath.
+ '''
+ '''
+ ''' Path does not have a parent path because it is a root path.
+ '''
+ '''
+ ''' is or an empty string.
+ '''
+ ''' The path exceeds the system-defined maximum length.
+ '''
+ ''' A file or directory name in the path contains a colon (:) or is in an invalid format.
+ '''
Public Function GetParentPath(path As String) As String
Return FileIO.FileSystem.GetParentPath(path)
End Function
+ '''
+ ''' Create a uniquely named zero-byte temporary file on disk and return the full path to that file.
+ '''
+ ''' A String containing the name of the temporary file.
Public Function GetTempFileName() As String
Return FileIO.FileSystem.GetTempFileName()
End Function
+ '''
+ ''' Move an existing directory to a new directory,
+ ''' throwing exception if there are existing files with the same name.
+ '''
+ ''' The path to the source directory, can be relative or absolute.
+ '''
+ ''' The path to the target directory, can be relative or absolute.
+ ''' Parent directory will always be created.
+ '''
+ '''
+ ''' The path is not valid for one of the following reasons: it is a zero-length string;
+ ''' it contains only white space; it contains invalid characters;
+ ''' or it is a device path (starts with \.\).
+ '''
+ '''
+ ''' or
+ ''' is or an empty string.
+ '''
+ ''' The directory does not exist.
+ ''' The path exceeds the system-defined maximum length.
+ ''' The operation is cyclic.
+ '''
+ ''' A file or directory name in the path contains a colon (:) or
+ ''' is in an invalid format.
+ '''
+ ''' The user lacks necessary permissions to view the path.
+ ''' The user lacks necessary permissions.
Public Sub MoveDirectory(sourceDirectoryName As String, destinationDirectoryName As String)
FileIO.FileSystem.MoveDirectory(sourceDirectoryName, destinationDirectoryName)
End Sub
+ '''
+ ''' Move an existing directory to a new directory, overwriting existing files with the same name if specified.
+ '''
+ ''' The path to the source directory, can be relative or absolute.
+ '''
+ ''' The path to the target directory, can be relative or absolute.
+ ''' Parent directory will always be created.
+ '''
+ '''
+ ''' to overwrite existing files with the same name.
+ ''' Otherwise .
+ '''
+ '''
+ ''' The path is not valid for one of the following reasons: it is a zero-length string;
+ ''' it contains only white space; it contains invalid characters;
+ ''' or it is a device path (starts with \.\).
+ '''
+ '''
+ ''' or
+ ''' is or an empty string.
+ '''
+ ''' The directory does not exist.
+ ''' The path exceeds the system-defined maximum length.
+ ''' The operation is cyclic.
+ '''
+ ''' A file or directory name in the path contains a colon (:) or
+ ''' is in an invalid format.
+ '''
+ ''' The user lacks necessary permissions to view the path.
+ ''' The user lacks necessary permissions.
Public Sub MoveDirectory(sourceDirectoryName As String, destinationDirectoryName As String, overwrite As Boolean)
FileIO.FileSystem.MoveDirectory(sourceDirectoryName, destinationDirectoryName, overwrite)
End Sub
+ '''
+ ''' Move an existing directory to a new directory,
+ ''' displaying progress dialog and confirmation dialogs if specified,
+ ''' throwing exception if user cancels the operation
+ ''' (only applies if displaying progress dialog and confirmation dialogs).
+ '''
+ ''' The path to the source directory, can be relative or absolute.
+ '''
+ ''' The path to the target directory, can be relative or absolute.
+ ''' Parent directory will always be created.
+ '''
+ '''
+ ''' Specifies whether To visually track the operation's progress.
+ ''' Default is .
+ '''
+ '''
+ ''' The path is not valid for one of the following reasons: it is a zero-length string;
+ ''' it contains only white space; it contains invalid characters;
+ ''' or it is a device path (starts with \.\).
+ '''
+ '''
+ ''' or
+ ''' is or an empty string.
+ '''
+ ''' The directory does not exist.
+ ''' The path exceeds the system-defined maximum length.
+ ''' The operation is cyclic.
+ '''
+ ''' A file or directory name in the path contains a colon (:) or
+ ''' is in an invalid format.
+ '''
+ ''' The user lacks necessary permissions to view the path.
+ ''' The user lacks necessary permissions.
Public Sub MoveDirectory(sourceDirectoryName As String, destinationDirectoryName As String, showUI As UIOption)
FileIO.FileSystem.MoveDirectory(sourceDirectoryName, destinationDirectoryName, showUI)
End Sub
+ '''
+ ''' Move an existing directory to a new directory,
+ ''' displaying progress dialog and confirmation dialogs if specified,
+ ''' throwing exception if user cancels the operation if specified.
+ ''' (only applies if displaying progress dialog and confirmation dialogs).
+ '''
+ ''' The path to the source directory, can be relative or absolute.
+ '''
+ ''' The path to the target directory, can be relative or absolute.
+ ''' Parent directory will always be created.
+ '''
+ '''
+ ''' Specifies whether To visually track the operation's progress.
+ ''' Default is .
+ '''
+ '''
+ ''' Specifies whether to throw an if the user clicks Cancel.>.
+ '''
+ '''
+ ''' The path is not valid for one of the following reasons: it is a zero-length string;
+ ''' it contains only white space; it contains invalid characters;
+ ''' or it is a device path (starts with \.\).
+ '''
+ '''
+ ''' or
+ ''' is or an empty string.
+ '''
+ ''' The directory does not exist.
+ ''' The path exceeds the system-defined maximum length.
+ ''' The operation is cyclic.
+ '''
+ ''' A file or directory name in the path contains a colon (:) or
+ ''' is in an invalid format.
+ '''
+ ''' The user lacks necessary permissions to view the path.
+ ''' The user lacks necessary permissions.
+ '''
+ ''' The user cancelled the operation and is set to .
+ '''
Public Sub MoveDirectory(
sourceDirectoryName As String,
destinationDirectoryName As String,
@@ -222,18 +1048,129 @@ Namespace Microsoft.VisualBasic.MyServices
FileIO.FileSystem.MoveDirectory(sourceDirectoryName, destinationDirectoryName, showUI, onUserCancel)
End Sub
+ '''
+ ''' Move an existing file to a new file. Overwriting a file of the same name is not allowed.
+ '''
+ ''' The path to the source file, can be relative or absolute.
+ '''
+ ''' The path to the destination file, can be relative or absolute.
+ ''' Parent directory will always be created.
+ '''
+ '''
+ ''' contains path information.
+ '''
+ '''
+ ''' or is Nothing or an empty string.
+ '''
+ ''' The source file is not valid or does not exist.
+ ''' A file in the target directory with the same name is in use.
+ '''
+ ''' A file or directory name in the path contains a colon (:) or is in an invalid format.
+ '''
+ ''' The path exceeds the system-defined maximum length.
+ ''' The user does not have required permission.
+ ''' The user lacks necessary permissions to view the path.
Public Sub MoveFile(sourceFileName As String, destinationFileName As String)
FileIO.FileSystem.MoveFile(sourceFileName, destinationFileName)
End Sub
+ '''
+ ''' Move an existing file to a new file. Overwriting a file of the same name if specified.
+ '''
+ ''' The path to the source file, can be relative or absolute.
+ '''
+ ''' The path to the destination file, can be relative or absolute.
+ ''' Parent directory will always be created.
+ '''
+ '''
+ '''
+ ''' to overwrite existing file with the same name.
+ ''' Otherwise .
+ '''
+ '''
+ ''' contains path information.
+ '''
+ '''
+ ''' or is Nothing or an empty string.
+ '''
+ ''' The source file is not valid or does not exist.
+ ''' A file in the target directory with the same name is in use.
+ '''
+ ''' A file or directory name in the path contains a colon (:) or is in an invalid format.
+ '''
+ ''' The path exceeds the system-defined maximum length.
+ ''' The user does not have required permission.
+ ''' The user lacks necessary permissions to view the path.
Public Sub MoveFile(sourceFileName As String, destinationFileName As String, overwrite As Boolean)
FileIO.FileSystem.MoveFile(sourceFileName, destinationFileName, overwrite)
End Sub
+ '''
+ ''' Move an existing file to a new file,
+ ''' displaying progress dialog and confirmation dialogs if specified,
+ ''' will throw exception if user cancels the operation.
+ '''
+ ''' The path to the source file, can be relative or absolute.
+ '''
+ ''' The path to the destination file, can be relative or absolute.
+ ''' Parent directory will always be created.
+ '''
+ '''
+ ''' Specifies whether To visually track the operation's progress.
+ ''' Default is .
+ '''
+ '''
+ ''' contains path information.
+ '''
+ '''
+ ''' or is Nothing or an empty string.
+ '''
+ ''' The source file is not valid or does not exist.
+ ''' A file in the target directory with the same name is in use.
+ '''
+ ''' A file or directory name in the path contains a colon (:) or is in an invalid format.
+ '''
+ ''' The path exceeds the system-defined maximum length.
+ ''' The user does not have required permission.
+ ''' The user lacks necessary permissions to view the path.
Public Sub MoveFile(sourceFileName As String, destinationFileName As String, showUI As UIOption)
FileIO.FileSystem.MoveFile(sourceFileName, destinationFileName, showUI)
End Sub
+ '''
+ ''' Move an existing file to a new file,
+ ''' displaying progress dialog and confirmation dialogs if specified,
+ ''' will throw exception if user cancels the operation if specified.
+ '''
+ ''' The path to the source file, can be relative or absolute.
+ '''
+ ''' The path to the destination file, can be relative or absolute.
+ ''' Parent directory will always be created.
+ '''
+ '''
+ ''' Specifies whether To visually track the operation's progress.
+ ''' Default is .
+ '''
+ '''
+ ''' Specifies whether to throw an if the user clicks Cancel.>.
+ '''
+ '''
+ ''' contains path information.
+ '''
+ '''
+ ''' or is Nothing or an empty string.
+ '''
+ ''' The source file is not valid or does not exist.
+ ''' A file in the target directory with the same name is in use.
+ '''
+ ''' A file or directory name in the path contains a colon (:) or is in an invalid format.
+ '''
+ ''' The path exceeds the system-defined maximum length.
+ ''' The user does not have required permission.
+ ''' The user lacks necessary permissions to view the path.
+ '''
+ ''' The user cancelled the operation and is set to .
+ '''
Public Sub MoveFile(
sourceFileName As String,
destinationFileName As String,
@@ -243,30 +1180,146 @@ Namespace Microsoft.VisualBasic.MyServices
FileIO.FileSystem.MoveFile(sourceFileName, destinationFileName, showUI, onUserCancel)
End Sub
+ '''
+ ''' Return an instance of a TextFieldParser for the given file.
+ '''
+ ''' The path to the file to parse.
+ ''' An instance of a TextFieldParser.
+ '''
+ ''' is Nothing or an empty string.
+ '''
+ ''' The file does not exist.
+ ''' The file is in use by another process, or an I/O error occurs.
+ ''' The path exceeds the system-defined maximum length.
+ '''
+ ''' A file or directory name in the path contains a colon (:) or is in an invalid format.
+ '''
+ '''
+ ''' A row cannot be parsed using the specified format. The exception message
+ ''' specifies the line causing the exception, while the ErrorLine property is assigned
+ ''' the text contained in the line.
+ '''
+ ''' The user lacks necessary permissions to view the path.
Public Function OpenTextFieldParser(file As String) As TextFieldParser
Return FileIO.FileSystem.OpenTextFieldParser(file)
End Function
+ '''
+ ''' Return an instance of a TextFieldParser for the given file using the given delimiters.
+ '''
+ ''' The path to the file to parse.
+ ''' A list of delimiters.
+ ''' An instance of a TextFieldParser
+ '''
+ ''' is Nothing or an empty string.
+ '''
+ ''' The file does not exist.
+ ''' The file is in use by another process, or an I/O error occurs.
+ ''' The path exceeds the system-defined maximum length.
+ '''
+ ''' A file or directory name in the path contains a colon (:) or is in an invalid format.
+ '''
+ '''
+ ''' A row cannot be parsed using the specified format. The exception message
+ ''' specifies the line causing the exception, while the ErrorLine property is assigned
+ ''' the text contained in the line.
+ '''
+ ''' The user lacks necessary permissions to view the path.
Public Function OpenTextFieldParser(file As String, ParamArray delimiters As String()) As TextFieldParser
Return FileIO.FileSystem.OpenTextFieldParser(file, delimiters)
End Function
+ '''
+ ''' Return an instance of a TextFieldParser for the given file using the given field widths.
+ '''
+ ''' The path to the file to parse.
+ ''' A list of field widths.
+ ''' An instance of a TextFieldParser
+ '''
+ ''' is Nothing or an empty string.
+ '''
+ ''' The file does not exist.
+ ''' The file is in use by another process, or an I/O error occurs.
+ ''' The path exceeds the system-defined maximum length.
+ '''
+ ''' A file or directory name in the path contains a colon (:) or is in an invalid format.
+ '''
+ '''
+ ''' A row cannot be parsed using the specified format. The exception message
+ ''' specifies the line causing the exception, while the ErrorLine property is assigned
+ ''' the text contained in the line.
+ '''
+ ''' The user lacks necessary permissions to view the path.
Public Function OpenTextFieldParser(file As String, ParamArray fieldWidths As Integer()) As TextFieldParser
Return FileIO.FileSystem.OpenTextFieldParser(file, fieldWidths)
End Function
+ '''
+ ''' Return a StreamReader for reading the given file using UTF-8 as preferred encoding.
+ '''
+ ''' The file to open the StreamReader on.
+ ''' An instance of System.IO.StreamReader opened on the file (with FileShare.Read).
+ '''
+ ''' ends with a backslash (\).
+ '''
+ ''' The file does not exist.
+ ''' The user lacks necessary permissions to view the path.
Public Function OpenTextFileReader(file As String) As IO.StreamReader
Return FileIO.FileSystem.OpenTextFileReader(file)
End Function
+ '''
+ ''' Return a StreamReader for reading the given file using the given encoding as preferred encoding.
+ '''
+ ''' The file to open the StreamReader on.
+ '''
+ ''' The preferred encoding that will be used if the encoding of the file could not be detected.
+ '''
+ ''' An instance of System.IO.StreamReader opened on the file (with FileShare.Read).
+ '''
+ ''' ends with a backslash (\).
+ '''
+ ''' The file does not exist.
+ ''' The user lacks necessary permissions to view the path.
Public Function OpenTextFileReader(file As String, encoding As Encoding) As IO.StreamReader
Return FileIO.FileSystem.OpenTextFileReader(file, encoding)
End Function
+ '''
+ ''' Return a StreamWriter for writing to the given file using UTF-8 encoding.
+ '''
+ ''' The file to write to.
+ '''
+ ''' to append to the content of the file.
+ ''' to overwrite the content of the file.
+ '''
+ ''' An instance of StreamWriter opened on the file (with FileShare.Read).
+ '''
+ ''' ends with a trailing slash.
+ '''
+ '''
+ ''' is Nothing or an empty string.
+ '''
Public Function OpenTextFileWriter(file As String, append As Boolean) As IO.StreamWriter
Return FileIO.FileSystem.OpenTextFileWriter(file, append)
End Function
+ '''
+ ''' Return a StreamWriter for writing to the given file using the given encoding.
+ '''
+ ''' The file to write to.
+ '''
+ ''' to append to the content of the file.
+ ''' to overwrite the content of the file.
+ '''
+ ''' The encoding to use to write to the file.
+ ''' An instance of StreamWriter opened on the file (with FileShare.Read).
+ '''
+ ''' ends with a trailing slash.
+ '''
+ '''
+ ''' is Nothing or an empty string.
+ '''
Public Function OpenTextFileWriter(
file As String,
append As Boolean,
@@ -275,34 +1328,192 @@ Namespace Microsoft.VisualBasic.MyServices
Return FileIO.FileSystem.OpenTextFileWriter(file, append, encoding)
End Function
+ '''
+ ''' Read the whole content of a file into a byte array.
+ '''
+ ''' The path to the file.
+ ''' A byte array contains the content of the file.
+ '''
+ ''' The path is not valid for one of the following reasons: it is a zero-length string;
+ ''' it contains only white space; it contains invalid characters;
+ ''' or it is a device path (starts with \.\).
+ '''
+ '''
+ ''' is or an empty string.
+ '''
+ ''' The file does not exist.
+ ''' The file is in use by another process, or an I/O error occurs.
+ ''' The path exceeds the system-defined maximum length.
+ ''' A folder name in the path contains a colon (:) or is in an invalid format.
+ ''' There is not enough memory to write the string to buffer.
+ ''' The user lacks necessary permissions to view the path.
Public Function ReadAllBytes(file As String) As Byte()
Return FileIO.FileSystem.ReadAllBytes(file)
End Function
+ '''
+ ''' Read the whole content of a text file into a string using UTF-8 encoding.
+ '''
+ ''' The path to the text file.
+ ''' A String contains the content of the given file.
+ '''
+ ''' The path is not valid for one of the following reasons: it is a zero-length string;
+ ''' it contains only white space; it contains invalid characters;
+ ''' or it is a device path (starts with \.\).
+ '''
+ '''
+ ''' is or an empty string.
+ '''
+ ''' The file does not exist.
+ ''' The file is in use by another process, or an I/O error occurs.
+ ''' The path exceeds the system-defined maximum length.
+ ''' A folder name in the path contains a colon (:) or is in an invalid format.
+ ''' There is not enough memory to write the string to buffer.
+ ''' The user lacks necessary permissions to view the path.
Public Function ReadAllText(file As String) As String
Return FileIO.FileSystem.ReadAllText(file)
End Function
+ '''
+ ''' Read the whole content of a text file into a string using the given encoding.
+ '''
+ ''' The path to the text file.
+ ''' The character encoding to use if the encoding was not detected.
+ ''' A String contains the content of the given file.
+ '''
+ ''' The path is not valid for one of the following reasons: it is a zero-length string;
+ ''' it contains only white space; it contains invalid characters;
+ ''' or it is a device path (starts with \.\).
+ '''
+ '''
+ ''' is or an empty string.
+ '''
+ ''' The file does not exist.
+ ''' The file is in use by another process, or an I/O error occurs.
+ ''' The path exceeds the system-defined maximum length.
+ ''' A folder name in the path contains a colon (:) or is in an invalid format.
+ ''' There is not enough memory to write the string to buffer.
+ ''' The user lacks necessary permissions to view the path.
Public Function ReadAllText(file As String, encoding As Encoding) As String
Return FileIO.FileSystem.ReadAllText(file, encoding)
End Function
+ '''
+ ''' Rename a directory, does not act like a move.
+ '''
+ ''' The path of the directory to be renamed.
+ ''' The new name to change to. This must not contain path information.
+ '''
+ ''' contains path information.
+ '''
+ '''
+ ''' or
+ ''' is or an empty string.
+ '''
+ ''' The directory does not exist.
+ '''
+ ''' There is an existing file or directory with the name specified in .
+ '''
+ ''' The path exceeds the system-defined maximum length.
+ '''
+ ''' A file or directory name in the path contains a colon (:) or is in an invalid format.
+ '''
+ ''' The user lacks necessary permissions to view the path.
+ ''' The user does not have required permission.
Public Sub RenameDirectory(directory As String, newName As String)
FileIO.FileSystem.RenameDirectory(directory, newName)
End Sub
+ '''
+ ''' Renames a file, does not change the file location.
+ '''
+ ''' The path to the file.
+ ''' The new name to change to. This must not contain path information.
+ '''
+ ''' contains path information or ends with a backslash (\).
+ '''
+ '''
+ ''' or
+ ''' is or an empty string.
+ '''
+ ''' The directory does not exist.
+ '''
+ ''' There is an existing file or directory with the name specified in .
+ '''
+ ''' The path exceeds the system-defined maximum length.
+ '''
+ ''' A file or directory name in the path contains a colon (:) or is in an invalid format.
+ '''
+ ''' The user lacks necessary permissions to view the path.
+ ''' The user does not have required permission.
Public Sub RenameFile(file As String, newName As String)
FileIO.FileSystem.RenameFile(file, newName)
End Sub
+ '''
+ ''' Overwrites or appends the specified byte array to the specified file,
+ ''' creating the file if it does not exist.
+ '''
+ ''' The path to the file.
+ ''' The byte array to write to the file.
+ '''
+ ''' to append the text to the existing content.
+ ''' to overwrite the existing content.
+ '''
+ '''
+ ''' is or an empty string.
+ '''
+ ''' The file does not exist.
+ ''' The file is in use by another process, or an I/O error occurs.
+ ''' The path exceeds the system-defined maximum length.
+ ''' A folder name in the path contains a colon (:) or is in an invalid format.
+ ''' There is not enough memory to write the string to buffer.
+ ''' The user lacks necessary permissions to view the path.
Public Sub WriteAllBytes(file As String, data() As Byte, append As Boolean)
FileIO.FileSystem.WriteAllBytes(file, data, append)
End Sub
+ '''
+ ''' Overwrites or appends the given text using UTF-8 encoding to the given file,
+ ''' creating the file if it does not exist.
+ '''
+ ''' The path to the file.
+ ''' The text to write to the file.
+ '''
+ ''' to append the text to the existing content.
+ ''' to overwrite the existing content.
+ '''
+ ''' is or an empty string.
+ '''
+ ''' The file does not exist.
+ ''' The file is in use by another process, or an I/O error occurs.
+ ''' The path exceeds the system-defined maximum length.
+ ''' A folder name in the path contains a colon (:) or is in an invalid format.
+ ''' There is not enough memory to write the string to buffer.
+ ''' The user lacks necessary permissions to view the path.
Public Sub WriteAllText(file As String, text As String, append As Boolean)
FileIO.FileSystem.WriteAllText(file, text, append)
End Sub
+ '''
+ ''' Overwrites or appends the given text using the given encoding to the given file,
+ ''' creating the file if it does not exist.
+ '''
+ ''' The path to the file.
+ ''' The text to write to the file.
+ '''
+ ''' to append the text to the existing content.
+ ''' to overwrite the existing content.
+ ''' The encoding to use.
+ '''
+ ''' is or an empty string.
+ '''
+ ''' The file does not exist.
+ ''' The file is in use by another process, or an I/O error occurs.
+ ''' The path exceeds the system-defined maximum length.
+ ''' A folder name in the path contains a colon (:) or is in an invalid format.
+ ''' There is not enough memory to write the string to buffer.
+ ''' The user lacks necessary permissions to view the path.
Public Sub WriteAllText(
file As String,
text As String,
diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/SpecialDirectoriesProxy.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/SpecialDirectoriesProxy.vb
index 781103586d4..c6e66fa7471 100644
--- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/SpecialDirectoriesProxy.vb
+++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/SpecialDirectoriesProxy.vb
@@ -2,12 +2,15 @@
' The .NET Foundation licenses this file to you under the MIT license.
Imports System.ComponentModel
+Imports System.IO
Imports Microsoft.VisualBasic.FileIO
Namespace Microsoft.VisualBasic.MyServices
'''
- ''' An extremely thin wrapper around Microsoft.VisualBasic.FileIO.SpecialDirectories to expose the type through My.
+ ''' This class contains properties that will return the Special Directories
+ ''' specific to the current user (My Documents, My Music ...) and those specific
+ ''' to the current Application that a developer expects to be able to find quickly.
'''
Public Class SpecialDirectoriesProxy
@@ -18,54 +21,156 @@ Namespace Microsoft.VisualBasic.MyServices
Friend Sub New()
End Sub
+ '''
+ ''' Returns the directory that serves as a common repository for data files
+ ''' from your application used by all users.
+ '''
+ '''
+ '''
+ ''' The path is empty, usually because the operating system does not support the directory.
+ '''
+ '''
+ ''' If a path does not exist, one is created.
+ ''' For additional details
+ ''' .
+ '''
Public ReadOnly Property AllUsersApplicationData() As String
Get
Return SpecialDirectories.AllUsersApplicationData
End Get
End Property
+ '''
+ ''' The path to the Application Data directory for the current user.
+ '''
+ '''
+ '''
+ ''' If a path does not exist, one is created.
+ ''' For additional details
+ ''' .
+ '''
+ '''
+ ''' The path is empty, usually because the operating system does not support the directory.
+ '''
Public ReadOnly Property CurrentUserApplicationData() As String
Get
Return SpecialDirectories.CurrentUserApplicationData
End Get
End Property
+ '''
+ ''' The path to the Desktop directory.
+ '''
+ '''
+ '''
+ ''' If a path does not exist, one is created.
+ ''' For additional details
+ ''' .
+ '''
+ '''
+ ''' The path is empty, usually because the operating system does not support the directory.
+ '''
Public ReadOnly Property Desktop() As String
Get
Return SpecialDirectories.Desktop
End Get
End Property
+ '''
+ ''' The path to the My Documents directory
+ '''
+ '''
+ '''
+ ''' If a path does not exist, one is created.
+ ''' For additional details
+ ''' .
+ '''
+ '''
+ ''' The path is empty, usually because the operating system does not support the directory.
+ '''
Public ReadOnly Property MyDocuments() As String
Get
Return SpecialDirectories.MyDocuments
End Get
End Property
+ '''
+ ''' The path to the My Music directory.
+ '''
+ '''
+ '''
+ ''' If a path does not exist, one is created.
+ ''' For additional details
+ ''' .
+ '''
+ '''
+ ''' The path is empty, usually because the operating system does not support the directory.
+ '''
Public ReadOnly Property MyMusic() As String
Get
Return SpecialDirectories.MyMusic
End Get
End Property
+ '''
+ ''' The path to the My Pictures directory.
+ '''
+ '''
+ '''
+ ''' If a path does not exist, one is created.
+ ''' For additional details
+ ''' .
+ '''
+ '''
+ ''' The path is empty, usually because the operating system does not support the directory.
+ '''
Public ReadOnly Property MyPictures() As String
Get
Return SpecialDirectories.MyPictures
End Get
End Property
+ '''
+ ''' The path to the ProgramFiles directory.
+ '''
+ '''
+ '''
+ ''' If a path does not exist, one is created.
+ ''' For additional details
+ ''' .
+ '''
+ '''
+ ''' The path is empty, usually because the operating system does not support the directory.
+ '''
Public ReadOnly Property ProgramFiles() As String
Get
Return SpecialDirectories.ProgramFiles
End Get
End Property
+ '''
+ ''' The path to the Programs directory.
+ '''
+ '''
+ '''
+ ''' If a path does not exist, one is created.
+ ''' For additional details
+ ''' .
+ '''
+ '''
+ ''' The path is empty, usually because the operating system does not support the directory.
+ '''
Public ReadOnly Property Programs() As String
Get
Return SpecialDirectories.Programs
End Get
End Property
+ '''
+ ''' The path to the Temp directory.
+ '''
+ '''
+ ''' This property will always return a valid value.
Public ReadOnly Property Temp() As String
Get
Return SpecialDirectories.Temp