При ответах использована статья с MSDN о функции DIR и практический пример на условие
alec 07.03.2001
От: alec 07.03.2001 12:49:01 Как определить существует ли файл? Господа, столкнулся с такой проблемой: в Аccеss´97 определял существует ли файл с помощью FileExist, а в Access2000 не получается. Как быть?
Alex 07.03.2001
От: 07.03.2001 14:51:17 Re:Как определить существует ли файл? Dir Function
Returns a String representing the name of a file, directory, or folder that matches a specified pattern or file attribute, or the volume label of a drive.
Syntax Dir[(pathname[, attributes])]
The Dir function syntax has these parts:
Part Description pathname Optional. String expression that specifies a file name — may include directory or folder, and drive. A zero-length string ("") is returned if pathname is not found. attributes Optional. Constant or numeric expression, whose sum specifies file attributes. If omitted, returns files that match pathname but have no attributes.
Settings The attributes argument settings are:
Constant Value Description vbNormal 0 (Default) Specifies files with no attributes. vbReadOnly 1 Specifies read-only files in addition to files with no attributes. vbHidden 2 Specifies hidden files in addition to files with no attributes. VbSystem 4 Specifies system files in addition to files with no attributes. vbVolume 8 Specifies volume label; if any other attributed is specified, vbVolume is ignored. vbDirectory 16 Specifies directories or folders in addition to files with no attributes.
Note These constants are specified by Visual Basic for Applications and can be used anywhere in your code in place of the actual values.
Remarks Dir supports the use of multiple character (*) and single character (?) wildcards to specify multiple files. -------------------------- Send feedback to MSDN.Look here for MSDN Online resources.
F. Mishanya 14.03.2001
От: F. Mishanya 14.03.2001 13:34:35 Re:Как определить существует ли файл? Попробуй dir:
If Dir("c: ext.txt", vbNormal) = "" Then 'файл не существует. End If