![]() |
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
To access the contents, click the chapter and section titles.
Visual Basic 6 Programming Blue Book: The Most Complete, Hands-On Resource for Writing Programs with Microsoft Visual Basic 6!
Chapter 14
|
Table 14.1 Wildcard characters. | ||
---|---|---|
File Specification | Matches | Does Not Match |
DATA*.* | DATA.DAT | MYDATA.DAT |
DATASEPT.DAT | DATES.TXT | |
DATASUMMARY.TXT | ||
DATA?.A* | DATA1.ASC | DATA.ASC |
DATA2.A | DATASEPT.ASC | |
DATAX.ARG | DATAX.DAT | |
*.* | All files | - |
where path is a string expression that specifies the folder to delete and can include a drive specification. If you try to delete a folder that does not exist or is not empty (contains one or more files or folders), an error is generated.
To create a new folder, use the MkDir statement
MkDir path
where path specifies the name of the folder to create and can include a full path and drive specification. If only a name is specified, the new folder is created in the current folder on the current drive.
To make another folder current, use the ChDir statement
ChDir path
where path specifies the new folder and can include a drive specification. If no drive is specified, ChDir changes the current folder on the current drive. ChDir does not change the current drive. If the current drive is C: and you execute
ChDir D:\DATA
the current directory on drive D: is changed to \Data. However, C: remains the current drive and the current directory on drive C: remains unchanged.
To make another drive current, use the ChDrive statement
ChDrive drive
where drive specifies the new drive to make current. Only the first character of drive is significant. Attempting to make an invalid drive current will generate an error.
To determine the current path on a specified drive, use the CurDir function
[path =] CurDir[(drive)]
where drive specifies the drive of interest. Only the first character of drive is significant; unless it refers to a valid drive, an error will be generated. If the drive argument is omitted, CurDir returns the current path on the current drive.
You can obtain the path of the current Visual Basic application by reading the App objects Path property:
CurrentPath = App.Path
This property returns the path where the project file (VBP) is located when the application is running in the Visual Basic environment, and the path where the executable file (EXE) is located when running the program as an executable file. This property is extremely useful when you want to be sure that a programs data or configuration files are stored in the same folder as the EXE file. Be aware that the value returned by this property does not include a trailing backslash, so you must add it when creating a fully qualified file name. The following code opens a file named CONFIG.DAT in the programs EXE directory:
Filename = App.Path Filename = Filename & \CONFIG.DAT Open Filename For Input as #1
TIP: Current Path Vs. Applications PathWhats the difference between the current path on a drive and an applications path? An applications path is simply the path to the folder containing the programs executable file. It has no special status, except that each application may want to keep certain files in this folder. A drives current path points to the current default folder on that drive. Each drive in our system can have only one default path at a time, and this information is maintained by the operating system (although it can be changed by programs). The default path is the location where file operations will take place if a particular path is not specified. For example, the statement
Open "C:DATA.TXT" For Output As #1will open a file in the folder pointed to by drive C:s current path. A drive letter followed by only a colon always refers to the drives current path. The operating system also keeps track of the default drive, which is the disk where file operations will occur if a specific disk is not requested. Thus
Open "DATA.TXT" For Output As #1would open the file on the default drive, in the folder indicated by that drives default path. Likewise
Open "\SALES\DATA.TXT" For Output As #1would open the file in the \SALES folder on the default drive.
Previous | Table of Contents | Next |
![]() |
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |