Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to know whether pen drive has files or not
#1
Not Solved
Please tell me these scripts.I tried a lot but I can't
1)Test Script to know whether pend rive has files or not?
2)If we copy a file (ex:song) into pen drive,how to check whether song is copied into pen drive using qtp script
Reply
#2
Not Solved
Hello Dipashri,
You will have to substitute the drive of your external device instead of C:\ in the below code.

find_file will search for a particular filename with its extension and report if it is found or not found. This should solve Query 1.

For Query 2 you have to use the same function but probably tweak it a bit if necessary. I will leave that for you to explore Smile

Code:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oWrite = objFSO.CreateTextFile("SearchResult.txt", True)
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

find_file "FileName","FileExtension"

Count = 0
Function find_file(FileName, Extension)
   Set colItems = objWMIService.ExecQuery("SELECT * FROM CIM_DataFile WHERE Drive = 'C:' AND FileName='" & filename & "' AND Extension='" & extension & "'",,48)
   For Each objItem in colItems
      oWrite.WriteLine("Found " & objItem.name)
      Count = Count + 1
   Next
  
  If Count = 0 Then
    oWrite.WriteLine("File Not Found")
  End If
End Function
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  QTP 11 - CreateFolder fails to create folder in shared network drive from Windows 7 Pallavi 3 3,609 02-25-2014, 02:04 PM
Last Post: guin.anirban
  QTP Should open files(say txt files) it can be n number from a folder. Shiv Y 1 2,794 12-18-2013, 01:45 AM
Last Post: mlkrqtp
  Using ALM parameters to drive QTP Brian.Osborne 0 5,079 06-19-2013, 11:23 PM
Last Post: Brian.Osborne
  Selecting a file from the Local Drive prempujaripati 1 2,039 04-03-2013, 09:37 AM
Last Post: basanth27

Forum Jump:


Users browsing this thread: 1 Guest(s)