前のトピック: GetFileAttributes - ファイル属性を返す次のトピック: GetFileStoreFree、GetFileStoreSize、および GetFileStoreUsage - 空き容量、総容量、および使用容量を返す


GetFileSize - ファイル サイズを返す

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

GetFileSize 関数では、ファイル サイズがバイトで示されます。

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

GetFileSize(filename as String) as Integer
filename

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

戻り値はバイトで示されます。

例: GetFileSize 関数

この例では、ファイル AUTOEXEC.BAT のサイズと作成日がレポートされます。

dim size as integer
dim time as DateTime
dim out as string

size=GetFileSize("C:¥AUTOEXEC.BAT")
if (size<>-1) then
	 out="File size: "+chr(9)+chr(9)+str(size)+" bytes"+ chr(10)
	 time=GetFileTime("C:¥AUTOEXEC.BAT")
	 out=out+"Creation date: "+chr(9)+str(time.month)+"/"+str(time.day)+"/"+str(time.year)
	 out=out+" "+str(time.hour)+":"+str(time.minute)+" "
	 MsgBox("Information on C:¥AUTOEXEC.BAT"+chr(10)+chr(10)+out)

else
	 MsgBox("Cannot find C:¥AUTOEXEC.BAT")
end if
end: