51Testing软件测试论坛

标题: 请教QTP能否判断文件后缀名 [打印本页]

作者: marspm    时间: 2009-8-7 14:19
标题: 请教QTP能否判断文件后缀名
现在我需要判断文件属性,如何区分exe后缀和txt后缀不同文件
谢谢高手了!
作者: marco    时间: 2009-8-7 14:59
Scripting Runtime Library   

FileSystemObject Objects
The FileSystemObject (FSO) object model contains the following objects and collections.

Object/Collection Description
FileSystemObject Main object. Contains methods and properties that allow you to create, delete, gain information about, and generally manipulate drives, folders, and files. Many of the methods associated with this object duplicate those in other FSO objects; they are provided for convenience.
Drive Object. Contains methods and properties that allow you to gather information about a drive attached to the system, such as its share name and how much room is available. Note that a "drive" isn't necessarily a hard disk, but can be a CD-ROM drive, a RAM disk, and so forth. A drive doesn't need to be physically attached to the system; it can be also be logically connected through a network.
Drives Collection. Provides a list of the drives attached to the system, either physically or logically. The Drives collection includes all drives, regardless of type. Removable-media drives need not have media inserted for them to appear in this collection.
File Object. Contains methods and properties that allow you to create, delete, or move a file. Also allows you to query the system for a file name, path, and various other properties.
Files Collection. Provides a list of all files contained within a folder.
Folder Object. Contains methods and properties that allow you to create, delete, or move folders. Also allows you to query the system for folder names, paths, and various other properties.
Folders Collection. Provides a list of all the folders within a Folder.
TextStream Object. Allows you to read and write text files.
作者: dreamever    时间: 2009-8-7 15:53
我以前的做法比较简单,用循环读取某个目录下所有的文件名,然后判断文件名中是否包含“.txt"或者".exe",虽然简单,但是很好用,
作者: marspm    时间: 2009-8-10 10:15
嗯,我现在的方法也是先获取文件名,然后用Instr来判断其中是包含exe还是txt




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2