更新 : 2007 年 11 月
FileSystem モジュールに含まれるプロシージャを使って、ファイル、ディレクトリまたはフォルダ、およびシステムに対する操作を実行します。
My 機能を使用すると、FileSystem を使用するよりもファイル I/O 処理の生産性とパフォーマンスが格段に向上します。詳細については、「My.Computer.FileSystem オブジェクト」を参照してください。
解説
このモジュールは、Visual Basic 言語キーワードと、ファイルおよびフォルダにアクセスするランタイム ライブラリ メンバをサポートします。
メンバ
|
|
使用例
GetAttr 関数を使って、ファイルおよびディレクトリまたはフォルダの属性を調べるコード例を次に示します。
Dim MyAttr As FileAttribute
' Assume file TESTFILE is normal and readonly.
MyAttr = GetAttr("C:\TESTFILE.txt") ' Returns vbNormal.
' Test for normal.
If (MyAttr And FileAttribute.Normal) = FileAttribute.Normal Then
MsgBox("This file is normal.")
End If
' Test for normal and readonly.
Dim normalReadonly As FileAttribute
normalReadonly = FileAttribute.Normal Or FileAttribute.ReadOnly
If (MyAttr And normalReadonly) = normalReadonly Then
MsgBox("This file is normal and readonly.")
End If
' Assume MYDIR is a directory or folder.
MyAttr = GetAttr("C:\MYDIR")
If (MyAttr And FileAttribute.Directory) = FileAttribute.Directory Then
MsgBox("MYDIR is a directory")
End If