Manipulating Files and Folders with

Manipulating Files and Folders ■ Finding Out the Name of the Active Folder ■ Changing the Name of a File or Folder ■ Checking the Existence of a File or Folder ■ Finding Out the Date and Time the File Was Modified ■ Finding Out the Size of a File ■ Returning and Setting File Attributes ■ Changing the Default Folder or Drive ■ Creating and Deleting Folders ■ Copying Files ■ Deleting Files ■ Writing to and Reading from Files ■ File Access Types ■ Working with Sequential Files ■ Working with Random Access Files ■ Working with Binary Files ■ Modern Methods of Working with Files and Folders ■ Finding Information about Files with WSH ■ Methods and Properties of the FileSystem-Object ■ Properties of the File Object ■ Properties of the Folder Object ■ Properties of the Drive Object ■ Creating a Text File Using WSH ■ Performing Other Operations with WSH ■ What's Next...

In the course of your work, you've surely accessed, created, renamed, copied, and deleted hundreds of files and folders. However, you've probably never performed these tasks programmatically. So here's your chance. This chapter focuses on VBA functions and instructions that specifically deal with files and folders. By using these functions, you'll be able to:

■ Find out the name of the current folder (CurDir function)

■ Change the name of a file or folder (Name function)

■ Check whether a file or folder exists on a disk (Dir function)

■ Find out the date and time a file was last modified (FileDateTime function)

■ Get the size of a file (FileLen function)

■ Check and change file attributes (GetAttr and SetAttr functions)

■ Change the default folder or drive (ChDir and ChDrive statements)

■ Create and delete a folder (MkDir and RmDir statements)

■ Copy and delete a file or folder (FileCopy and Kill statements)

In addition, this chapter gives you a working knowledge of writing to and retrieving data from three types of files: sequential, random access, and binary files. Instead of using the application's interface, you will learn how to work with files directly. At the end of this chapter, you will be introduced to the newest method of working with files and folders by utilizing the tool known as the Windows Scripting Host (WSH).

Was this article helpful?

0 0

Post a comment