前のトピック: ExistDir または ExistDirectory - ディレクトリの有無の調査次のトピック: FindClose - 検索処理の終了


ExistFile - ファイルの有無の調査

NetWare、Symbian OS、UNIX、Windows、および Windows CE で有効です。

ExistFile 関数はファイルの有無を調べます。

ファイルの内容に関するこの関数の形式は、以下のとおりです。

ExistFile(filename as String) as Boolean
filename

ファイル パスを識別します。

ファイルが存在する場合、関数の戻り値は True、それ以外の場合は False です。

例: ExistFile 関数

Dim file, section, entry, value as string

Dim LF, CR as char
Dim rtr as integer

ClrScr()
LF = 0x0a
CR = 0x0d
file = "c:¥dmscript.ini"
if Not(ExistFile(file)) then
	rtr = CreateFile(file, O_TEXT)
	if rtr = -1 then
		SetStatus(1)
		exit
	end if
	closeFile(rtr)
end if
	
section = "Section 1"
value = "Param_1 = Wert_1" + LF + "Param_2 = Wert_2"

if WriteIniSection( section, value, file) then
	Print("WriteIniSection successfully completed.")
else
	Print("WriteIniSection failed.")
endif

section = "Section 2"
entry = "Param_3"
value = "Wert_3"

if WriteIniEntry( section, entry, value, file) then
	Print("WriteIniFile successfully completed.")
else
	Print("WriteIniFile failed.")
endif

section = "Section 1"
rtr = ReadIniSection(section, value, file)
if (rtr > 0) then
	Print( Str(rtr) + CR + LF + value)
else
	Print("ReadIniSection failed.")
endif

section = "Section 2"
entry = "Param_3"
rtr = ReadIniEntry(section, entry, value, file)

if (rtr > 0) then
	Print( Str(rtr) + CR + LF + entry + " = " + value)
else
	Print("ReadIniEntry failed.")

endif