Sunday, November 21, 2010

FSO Examples

Set fso = CreateObject ("Scripting.FileSystemObject")
If fso.FolderExists ("C:\parent") Then
 ' fso.GetParentFolderName ("C:\parent")            '- displays C:/
 'msgbox fso.GetFolder("C:\parent").IsRootFolder       ' false
     'icount = fso.GetFolder("C:\parent").SubFolders.Count     ' returns count
    Set f = fso.GetFolder("c:\parent")
    Set sf = f.SubFolders
  For Each f1 in sf
   s = s & f1.name
   s = s & ";"
  Next
   ShowFolderList = s
End If
  msgbox ShowFolderList
  ' lst = Array(10)    
  lst = split (ShowFolderList, ";")
  icount = ubound(lst)
  For i=0 to icount-1 step 1
   msgbox lst(i)
  Next
 
  'msgbox arr()
'set obj = CreateObject ("WScript.Shell")
'set oExec = obj.Exec ("perl c:\Perl\eg\example.pl")
'msgbox oExec.Status
'If  oExec.Status = 0 Then
' Reporter.ReportEvent micWarning, perlscript, "Success"
' Else
' Reporter.ReportEvent micWarning, perlscript, "Fail"
'End If
'Set fso = CreateObject ("Scripting.FileSystemObject")
'If  fso.FolderExists ("C:\QTPPractice")  Then
' msgbox "Folder Already Exists"
' Reporter.ReportEvent micWarning, FolderExits, "Folder Already Exists"
'Else
'  fso.CreateFolder ("C:\QTPPractice")
'       '  set fileobj = fso.CreateTextFile ("C:\QTPPractice\textfile.txt", ForWriting, True)
'  set fileobj = fso.CreateTextFile ("C:\QTPPractice\textfile.txt")
'  msgbox "Folder and File Created"
'  Reporter.ReportEvent micPass, FolderExits, "Folder and File Created"
'End If

No comments:

Post a Comment

 

©2010 Software Testing powered by Free Blogger Templates | Author : Anand Satish