Thursday, August 4, 2011

File System Statement : Part I


ChDir

Purpose : The ChDir statement changes the current working directory on the specified drive.

Syntax :
ChDir path$

path$ must be a string in the format of
[drive:] [\] dir [\subdir] [\subdir...]

ChDir "D:\MYDIR"
ChDir "\MAIN\MAILBOX"
ChDir "\\MySERVER\MAIN\MAILBOX"

The ChDir statement can affect the operation of file -related commands
Path$ is not longer then 128 characters
 
----------------------------------------------
 

ChDriver

Purpose : The ChDrive statement changes the current default drive.

Syntax :
ChDrive Drive$

ChDrive "A"
ChDirive "C:"
 
----------------------------------------------
 
CurDir, CurDir$
Purpose : The CurDir$ or CurDir function returns the current default directory for the specified drive.

Syntax :
CurDir [ ( drive$ ) ]
CurDir$ [ ( drive$ ) ]

Default$ = CurDir
A$ = CurDir ( " C " )
CDirectory = CurDir ( " C: " )

----------------------------------------------

Dir, Dir$

Purpose : The Dir and Dir$ function return a filename that matches the supplied pattern, file attribute or volume label of a drive . the Dir$ function is retained of backward compatibility.

Syntax :
For the first call to Dir

Dir [ ( pattern$ [ , Attributes ] ) ]

For each successive call for the same pattern :

Dir

Temp$ = Dir ( "*.DOC" )
Do Until Temp$ = ""
i=i+1
Docs ( i ) = Temp$
Temp$ = Dir
Loop
Temp$ = Dir ( "*.*" , vbHidden )
Temp$ = Dir ( "c:\ " , vbDirectory )

Constants used with the Dir function
Constant : Value : Description
vbNormal : 0 : Normal
vbHidden : 2 : Hidden
vbSystem : 4 : System file
vbVolume : 8 : Volume label;
vbDirectory : 16 : Directory
 
-----------------------------------------------

FileCopy

Purpose : Use the FileCopy statement to copy a file. this is similer to the DOS copy command.

Syntax :
FileCopy source$ , dest$

FileCopy " temp.tem" , dataFileName

This command copies a xopies a DOS file. the source$ file can be opened for read-only access but must not be opened for write access. You can specify a drive and directory in either of the filenames, but you cannot specify any wildcards. The sample syntax copies the file TEMP.TEM to the filename specifed by the variable dataFileName
 
-----------------------------------------------

FileDateTime

Purpose : The FileDateTime function returns a date that indicates the date and time a file was created or last modified.

Syntax :
FileDateTime ( filename$

lastSaved = CVDate ( fileDateTime ( "DATAFILE.MDB" )

Usethe FileDateTime function to datermine when a DOS file was created or last saved. The function returns a date.
 
-----------------------------------------------

FileLen

Purpose : the FileLen function returns the total length of a file in bytes.

Syntax :
FileLen ( filename$ )

totalBytes = FileLen ( Dir ( ) )

It return a long integer indicating the total number of bytes in the file.

No comments:

Post a Comment