File system object in vb script
Filesystemobject can be used to work with drives, folders, and files.
Filesystemobject has methods and properties that allow us to create, delete, gain information about, and generally manipulate drives, folders, and files.
Important Methods of filesystemobject in vb script
- CopyFile
- CopyFolder
- CreateFolder
- CreateTextFile
- DeleteFile
- DeleteFolder
- DriveExists
- FileExists
- FolderExists
- GetAbsolutePathName
- GetBaseName
- GetDrive
- GetDriveName
- GetExtensionName
- GetFile
- GetFileName
- GetFolder
- GetParentFolderName
- GetSpecialFolder
- GetTempName
- MoveFile
- MoveFolder
- OpenTextFile
Working with files
Creating and writing to file
You can create a text file using this object.
Set obj = createobject("scripting.filesystemobject") set f = obj.createtextfile("g:\salunke.txt") ' create a file f.write str ' write some data into file set f= nothing ' release memory set obj = nothing
Reading from the file character by character
Set fo = createobject("scripting.filesystemobject")
set stream1= fo.OpenTextFile("c:\abc.txt",1) msgbox stream1.AtEndOfStream Do While (stream1.AtEndOfStream <> true ) msgbox stream1.Read(1) loop stream1.Close Set stream1 = nothing
Appending data to file
set stream1= fo.OpenTextFile("c:\abc.txt",8)
stream1.Write("append it") stream1.Close Set stream1 = nothing Set fo = nothing
Working with Folders
We can create, delete folders.
trabzon
ReplyDeleteedirne
van
bingöl
yalova
OJY1