File and Folder Statements & Functions

 


TABLE OF CONTENTS


 File, Folder, and Directory Statements

Statement

What it Does

Comments

ChDir path

Changes the current directory to the one specified by path

Changes only the directory, not the drive

ChDrive drive

Changes the current drive to the one specified by drive

Changes only the drive, not the directory

Close filenumberlist

Closes any files opened with the Open statement

Files closed correspond to the numbers specified in filenumberlist

FileCopy source, dest

Copies the filename and path specified by source to the filename and path specified by dest

 

Get [#]filenumber_

{, recnumber} varname

Reads data from an open disk file corresponding to filenumber into a variable specified by varname

Works with files open as Random or Binary. For Random files, a record number, recnumber, must be specified. For Binary files, recnumber is used to specify the byte position from which the data s to be read

Input #filenumber, _varlist

Reads data from the open file associated with the filenumber argument and places it in the varlist argument

varlistcontains one or more comma- delimited variables

Kill pathname

Deletes the file(s) or directory represented by pathname

pathname can contain wildcards

Line Input #_filenumber, varname

Reads a line of data (ending with a carriage return or linefeed) from the open file corresponding to filenumber

The data is stored in a String or Variant specified by varname

Lock [#] filenumber_

[,recnumber | start To end]

Prevents another process from accessing all or part of the open file corresponding to the filenumber

recnumber specifies the recordnumber (for Random files) or byte position (for Binary files) where locking should begin.

 

Alternatively, start To end specifies the range of records (or bytes) that should be locked.

Load object

Loads an object, such as a form or control, into memory.

 

MkDir path

Creates the new directory or folder specified by path

 

Name oldpath As newpath

Renames the file, directory, or folder specified by oldpathto one specified by newpath

 

Open strfilename _

[For mode] As #intfilenumber

Opens a file for input or output and assigned it to a given intfilenumber

strfilename is a string value or variable containing a file name. mode must be Append, Input, or Output

Print # filenumber_ [Spaces(n)|Tab(n)]_

[expression][charpos]

Writes data to the open sequential file that corresponds to filenumber

Spaces specifies that the printer should write n spaces. Tab indicates that the carriage return should be advanced to the nth character position. expression can be used to specify the data to be written and charpos can specify the insertion position for the next character.

Put [#] filenumber_

[, recnumber], varname

Writes data to the open disk file associated with filenumber from a variable varname

 

Reset

Closes all files opened with an Open statement

Writes buffer contents (if any) to disk before closing

RmDir path

Removes the directory or folder specified by path

 

Seek [#]filenumber, _position

Sets the record or byte position of the open file associated with filenumber

 

Seek (filenumber)

 

Returns a Long specifying the current record or byte position for the open file associated with filenumber.

When dealing with Random files, Seek returns the number of the next record to be read or written. For all other file types, Seek returns a byte position.

SetAddr pathname, attributes

Sets attributes for the file or directory specified by pathname

Attributes are specified by VB constants (vbNormal,vbReadOnly, vbArchive,vbSystem, vbHidden,vbDirectory)

Unload object

Unloads an object (such as a form or control) from memory and frees up any resources being used by the object.

 

Unlock [#]filenumber_ [, recnumber|[start] To end)]

Removes locking that prevents another process from accessing all or part of the open file designated by filenumber

For Random files, recnumber is the record number; for Binary files, it's the byte position. Alternatively, starting or ending record numbers (for Random files) or byte positions (for Binary files) can be specified.

Width #filenumber, width

Specifies the output line character width for the open file corresponding to filenumber

 

Write # filenumber, [outputlist]

Writes data to the open sequential file corresponding to filenumber

The outputlist should contain one or more comma-delimited variables that constitute what s to be output to the file

Go Back to Top

 

File, Folder, and Directory Functions

Function

What it Does

Comments

Dir(pathname_

[, attributes])

Returns a String value containing the name of a file, directory, or folder matching the pattern specified pathnameand/or a file attribute (as specified in attributes).

 

When the Dir function is first called, it returns the name of a file based on the pathname and attributes arguments. If the function is called again and no arguments are given, it returns the second file name for the given pathname and attributes, etc.

EOF(filenumber)

Returns a True or False value (Integer) indicating whether the end of file marker has been reached for the Random or Input file associated filenumber.

 

FileAttr(filenumber, _ returntype)

Returns a Long value representing the file mode for a file opened via the Open statement. 

filenumber is the file number for the open file, and returntypeis the type of information to be returned.. Possible values returned by the FileAttr function for indicating file type are: 1 for Input, 2 for Output, 4 for Random, 8 for Append, and 32 for Binary.

FileDateTime()

Returns a Variant that gives the date and time when the file specified by pathname was lastmodified.

 

FileLen()

Returns a Long value giving the size (in bytes) of the file specified by pathname.

 

FreeFile[rangenumber]

Returns an Integer value the represents the next file number available for use with the Open statement.

 

rangenumber (optional) is used to specify which range of file numbers should be used: 0 (the default) for file numbers in the range of 1-255, or 1 for file numbers in the range of 256-511.

GetAttr(pathname)

Returns an Integer value that represents the attributes for the file, directory, or folder specified by pathname.

 

To determine which attributes are set, the value returned can be compared bitwise with various VB constants (vbNormal, vbReadOnly, vbHidden, vbSystem, vbDirectory, and vbArchive).

LoadPicture( _ [stringexpression])

Loads the image specified by stringexpressionand returns it.

 

Permits pictures to be loaded and assigned to a Form's Picture property, a PictureBox control, or an Image control. If no stringexpression argument is given, then LoadPicture returns an empty picture.

LoadResData(index, _ format)

Loads data from the resource (.RES) file with the identifier of index

 

format is the format of the data (1 = cursors, 2 = bitmaps, 3 = icons, 4 = menus, 5 = dialog boxes, 6 = strings, 7 = font directories, 8 = fonts, 9 = accelerator tables, 10 = user-defined resources, 12 = group cursors, and 14 = group icons). Data returned by LoadResData can be assigned to a variable or object of the appropriate type.

LoadResPicture _ (index,format)

Loads a bitmap, icon, or cursor from the resource (.RES) file with the identifier of index.

 

format specifies the format of the data (0 = bitmaps, 1 = icons, and 2 = cursors). The data returned by LoadResPicture can be assigned to an object of the appropriate type.

LoadResString(index)

Loads a string from the resource (.RES) file with the identifier of index. 

The string that is returned can be assigned to a String or Variant.

Loc(filenumber)

Returns a Long value that s the current byte position within the open file that corresponds to filenumber. 

 

LOF(filenumber)

Returns a Boolean value that's the byte size of the open file that corresponds to filenumber.

 

SavePicture picture, _ stringexpression

Saves an graphic image from an object's Picture or Image property to a file.

picture specifies the control from which the graphics file (Picture or Image) is to be created , and stringexpression specifies the path and filename to which the image is saved.

Go Back to Top

arrowl2Return to the Visual Basic 6 Commands & Functions Page

Comments

 

Latest Version! NetObjects Fusion 10 

 

Copyright 1998 Rich Hamper 

All Rights Reserved

 

Last Updated:

Sunday, January 20, 2008