Single Post

Header

Sunday, September 30, 2012

FileSystemObject in VBScript

' All the functions under FileSystemObject
set files = createobject("scripting.filesystemobject")
'set f1=files.createtextfile("d:\test.txt")

' File Append Mode
set f_appendmode=files.opentextfile("d:\test1.txt",8,true)
f_appendmode.writeline("welcome to file append mode")

' File ReWrite Mode
set f_rewritemode=files.opentextfile("d:\test2.txt",2,true)
f_rewritemode.writeline("welcome to file re write mode")

' File Read Mode
set f_readmode=files.opentextfile("d:\test1.txt",1,true)
str=f_readmode.readline
msgbox str

' File Exists or Not
path="d:\test1.txt"
if files.fileexists(path) then
msgbox "the file "&path&" exists"
end if

' File Create,Copy,Delete Operations
files.createtextfile("d:\test3.txt")
files.copyfile "d:\test3.txt", "c:\"
files.deletefile "d:\test3.txt"

set fso=files.getfile(path)
msgbox files.getparentfoldername(path)

' If u want to work with folders replace the word 'file' woth 'folder'



msgbox "completed successfully"

No comments:

Post a Comment