Below a simple example of how to obtain a File and Folder various properties. VBA CopyFile. VBA CopyFolder. VBA CreateFolder. VBA DeleteFile. VBA DeleteFolder. Drive is an Object. Contains methods and properties that allow you to gather information about a drive attached to the system. Drives is a Collection. It Provides a list of the drives attached to the system, either physically or logically. File is an Object. It Contains methods and properties that allow developers to create, delete or move a file.
Folder is an Object. It Provides methods and properties that allow developers to create, delete or move folders. Step 1: After we have created a new FileSystemObject, use IF statement to determine whether a folder exists or not as follows,. Step 2: If the folder exists we want to display folder exists and if does not we want it to display that folder does not exists. Now since we discussed that FSO has various objects such as drives. Let us find out how much space I have available in my E drive.
Step 2: Now declare a variable as FileSystemObject and set it to new instance as follows,. Step 3: Now since we are using the Drive property declare one variable as Drive type and one variable as double to hold the data for space as follows,. Step 5: We will use another FSO method to get the free space of the drive and store it in the variable defined for storing the drive space,.
Step 7: Now display the value stored in for Drive space using the msgbox function as follows,. Step 3: Now we will use Create Folder method to create a new folder to a specified location,. You can also go through our other suggested articles —. GetAbsolutePathName Returns the complete path from the root of the drive for the specified path.
GetBaseName Returns the base name of a specified file or folder. GetDrive Returns a Drive object corresponding to the drive in a specified path. GetDriveName Returns the drive name of a specified path. GetExtensionName Returns the file extension name for the last component in a specified path. GetFile Returns a File object for a specified path.
GetFileName Returns the file name or folder name for the last component in a specified path. GetFolder Returns a Folder object for a specified path. GetParentFolderName Returns the name of the parent folder of the last component in a specified path. GetTempName Returns a randomly generated temporary file or folder. Move Moves a specified file or folder from one location to another. MoveFile Moves one or more files from one location to another. MoveFolder Moves one or more folders from one location to another.
OpenAsTextStream Opens a specified file and returns a TextStream object that can be used to read from, write to, or append to the file.
0コメント