VBScript ファイルサイズの取得方法

ファイルサイズの取得方法です。

 

WScript.Echo FileSize "c:\tmp\sample.txt"

'** ファイルサイズ取得
'****************************
Function FileSize(path)
	SysWriter "FileSize関数を開始します。", sysLogPath
	Dim objFso
	Dim objFile
	Set objFso = CreateObject("Scripting.FileSystemObject")
	If objFso.FileExists(path) Then
		Set objFile = objFso.GetFile(path)
		FileSize = objFile.Size
		SysWriter "ファイルサイズ:" & objFile.Size, sysLogPath
	Else
		FileSize = 0
		SysWriter "ファイルサイズ:0", sysLogPath
	End If
	SysWriter "FileSize関数を終了します。", sysLogPath
	Set objFile = Nothing
	Set objFso = Nothing
End Function

Bookmark this on Yahoo Bookmark
Bookmark this on Google Bookmarks
Share on LinkedIn
LINEで送る
Pocket