次の方法で共有


FileSystem モジュール (Visual Basic)

更新 : 2007 年 11 月

FileSystem モジュールに含まれるプロシージャを使って、ファイル、ディレクトリまたはフォルダ、およびシステムに対する操作を実行します。

My 機能を使用すると、FileSystem を使用するよりもファイル I/O 処理の生産性とパフォーマンスが格段に向上します。詳細については、「My.Computer.FileSystem オブジェクト」を参照してください。

解説

このモジュールは、Visual Basic 言語キーワードと、ファイルおよびフォルダにアクセスするランタイム ライブラリ メンバをサポートします。

メンバ

ChDir

ChDrive

CurDir

Dir

EOF

FileAttr

FileClose

FileCopy

FileDateTime

FileGet

FileGetObject

FileLen

FileOpen

FilePut

FilePutObject

FileWidth

FreeFile

GetAttr

Input

InputString

Kill

LineInput

Loc

Lock

LOF

MkDir

Print

PrintLine

Rename

Reset

RmDir

Seek

SetAttr

SPC

Tab

Unlock

Write

WriteLine

 

 

使用例

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

参照

参照

ディレクトリとファイルの概要

入出力の概要

キーワードとメンバ (タスク別)

Visual Basic 言語のキーワード

Visual Basic ランタイム ライブラリのメンバ

各言語のキーワードの比較