Filesystem

1.18 Filesystem

ChDir Procedure

Microsoft.VisualBasic.FileSystem


ChDir(path)

 

path required; String

The path of the directory to set as the new default directory

Description

Changes the current working (default) directory.

ChDrive Procedure

Microsoft.VisualBasic.FileSystem


ChDrive(drive)

 

drive required; String or Char

The letter of the drive (A-Z) to set as the new default drive

Description

Changes the current working (default) disk drive.

CurDir Function

Microsoft.VisualBasic.FileSystem


CurDir[(drive)]

 

drive optional; String or Char

The name of the drive

Return Value

A String containing the current path

Description

Returns the current directory of a particular drive or the default drive.

If no drive is specified or if drive is a zero-length string (""), CurDir returns the path for the current drive.

drive can be the single-letter drive name with or without a colon (i.e., both "C" and "C:" are valid values for drive).

If drive is invalid, the function will generate an 10Exception exception.

Because CurDir can only accept a single-character string, you cannot use network drive names, share names, or UNC drive names.

Dir Function

Microsoft.VisualBasic.FileSystem


Dir[(pathname[, attributes])]

 

pathname optional; String

A string expression that defines a path, which may contain a drive name, a folder name, and a filename

attributes optional; Numeric or Constant of the FileAttribute enumeration

The file attributes to be matched

Return Value

String

Description

Returns the name of a single file or folder matching the pattern and attribute passed to the function.

A zero-length string ("") is returned if a matching file is not found.

Possible values for attributes are:

FileAttributeenumeration

Value

Description

Normal

0

Normal (not hidden and not a system file)

ReadOnly

1

Read-only file

Hidden

2

Hidden

System

4

System file

Volume

8

Volume label; if specified, all other attributes are ignored

Directory

16

Directory or folder

Archive

32

Archive

Alias

64

Alias or link

 

FileCopy Procedure

Microsoft.VisualBasic.FileSystem


FileCopy(source, destination)

 

source required; String

The name of the source file to be copied

destination required; String

The name and location of the file when copied

Return Value

None

Description

Copies a file.

FileDateTime Function

Microsoft.VisualBasic.FileSystem


FileDateTime(pathname)

 

pathname required; String

The filename, along with an optional drive and path

Return Value

A Date containing the date and time at which the specified file was created or last modified

Description

Obtains the date and time at which a particular file was created or last modified (whichever is later).

GetAttr Function

Microsoft. VisualBasic.FileSystem


GetAttr(pathname)

 

pathname required; String

Filename and an optional pathname

Return Value

An integer representing the sum of the following constants or members of the FileAttribute enumeration, which reflect the attributes set for the file:

FileAttribute Numeration

Constant

Value

Description

Normal

VbNormal

0

Normal

ReadOnly

VbReadOnly

1

Read-only

Hidden

VbHidden

2

Hidden

System

VbSystem

4

System

Directory

VbDirectory

16

Directory or folder

Archive

VbArchive

32

File has changed since last backup

Description

Determines which attributes have been set for a file or directory

Kill Procedure

Microsoft.VisualBasic.FileSystem


Kill(pathname)

 

pathname required; String

The file or files to be deleted

Description

Deletes a file from disk. The ? and * wildcard characters can be used to specify multiple files.

MkDir Procedure

Microsoft.VisualBasic.FileSystem


MkDir(path)

 

path required; String

The name of the folder to be created

Description

Creates a new folder.

Rename Procedure

Microsoft.VisualBasic.FileSystem


Rename(oldpath, newpath)

 

oldpath required; String

The current filename and optional path

newpath required; String

The new filename and optional path

Description

Renames a disk file or folder.

RmDir Procedure

Microsoft.VisualBasic.FileSystem


RmDir(path)

 

path required; String

The path of the folder to be removed

Description

Removes a folder.

SetAttr Procedure

Microsoft.VisualBasic.FileSystem


SetAttr(pathname, attributes)

 

pathname required; String

The name of the file or directory whose attributes are to be set

attributes required; FileAttribute enumeration

Numeric expression, FileAttribute enumerated constant, or global VB constant specifying the attributes

Description

Changes the attribute properties of a file.

You can use any sum of the following constants to set the attributes of a file:

Constant

Value

Description

VbNormal

0

Normal

VbReadOnly

1

Read-only

VbHidden

2

Hidden

VbSystem

4

System

VbArchive

32

File has changed since last backup

Each global constant has a corresponding constant in the FileAttribute enumeration. For example, vbNormal is identical to FileAttribute.Normal. The file-attribute constants vbDirectory, vbAlias, and vbVolume cannot be used when assigning attributes.

File-attributes constants can be Ored to set more than one attribute at the same time. For example:

SetAttr "SysFile.Dat", FileAttribute.System Or FileAttribute.Hidden

Unlock Procedure

Microsoft.VisualBasic.FileSystem


Unlock(filenumber[, record)
Unlock(filenumber[, fromrecord[, torecord]])

 

filenumber required; Integer

Any valid file number

record required; Long

The record or byte number at which to commence the lock

fromrecord required; Long

The first record or byte number to lock

torecord required; Long

The last record or byte number to lock

Description

Use the Unlock procedure in situations where more than one part of your program may need read and write access to the same data file. The Unlock procedure removes a lock that the Lock procedure placed on a section of the file or the whole file.

Write Procedure

Microsoft.VisualBasic.FileSystem


Write(filenumber, output)

 

filenumber required; Integer

Any valid file number

output required; Object (any)

A comma-delimited list of expressions or a ParamArray to be written to the file.

Named Arguments

No

Description

Writes data to a sequential file

WriteLine Procedure

Microsoft.VisualBasic.FileSystem


WriteLine(filenumber, [output])

 

filenumber required; Integer

Any valid file number

output optional; Object (any)

A comma-delimited list of expressions or a ParamArray to be written to the file

Named Arguments

No

Description

Writes data to a sequential file and then adds a line-feed character combination

 



VB. NET Language Pocket Reference
VB.NET Language Pocket Reference
ISBN: 0596004281
EAN: 2147483647
Year: 2002
Pages: 31

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net