
September 2nd, 2008 by

daniva

Loading ...
file attributes are like switches. If the switch for Hidden is on, the file is a hidden file. If the switch for Hidden is off, the file is not a hidden file.
This analogy can be carried further by noting that light switches are typically under your control: you can choose to turn them on, or you can choose to turn them off.
In this QTip we are going to write a generic function that would retrieve a folder attributes as a string abbreviation.

May 15th, 2008 by

Yaron Assa

Loading ...
Create standard ZIP archives with only a few commands.

May 15th, 2008 by

Yaron Assa

Loading ...
Extract ZIP files with only a few simple commands

March 31st, 2008 by

daniva

Loading ...
The following code example shows how to use the I/O classes to create a listing of all files with the extension “.exe” in a directory.
The output data is inserted to the local data sheet and also printeg to the QTP log.

March 31st, 2008 by

daniva

Loading ...
The following code example shows how to use the I/O classes to create a listing of all files with the extension “.exe” in a directory.
The output data is inserted to the local data sheet and also printeg to the QTP log.

March 31st, 2008 by

daniva

Loading ...
System.IO.DirectoryInfo class exposes instance methods for creating, moving, and enumerating through directories and subdirectories.
System.IO.File Provides static methods for the creation, copying, deletion, moving, and opening of files.

March 31st, 2008 by

daniva

Loading ...
System.IO.DirectoryInfo class exposes instance methods for creating, moving, and enumerating through directories and subdirectories.

March 31st, 2008 by

daniva

Loading ...
the example list all folders under QTP installation folder. optionally you can load the output to an array, id you need to iterate the list.

March 31st, 2008 by

daniva

Loading ...
the example list all folders under C:\Automation. optionally you can load the output to an array, id you need to iterate the list.

March 31st, 2008 by

daniva

Loading ...
Dir displays a list of files and subdirectories in a directory.

March 31st, 2008 by

daniva

Loading ...
the WMI class Win32_Directory and noticed the property FileSize. Based on that, you might think, “Well, obviously I could just write a WMI script to get the folder size.” In turn you might write a script very similar to this one, which tries to determine the size of the folder C:\Scripts on the computer atl-ws-01:

March 31st, 2008 by

daniva

Loading ...
All we have to do is write a WMI query that includes the path of the folder we want to check as well as the file extension we’re checking for. For example, this script retrieves a collection of all the .bak files found in the C:\Logs folder:

March 31st, 2008 by

daniva

Loading ...
System.IO.File class provides static methods for the creation, copying, deletion, moving, and opening of files, and aids in the creation of FileStream objects.
The System.IO.StreamWriter class implements a TextWriter for writing characters to a stream in a particular encoding.
The following code examples show how to write text to a text file.

March 31st, 2008 by

daniva

Loading ...
System.IO.File class provides static methods for the creation, copying, deletion, moving, and opening of files, and aids in the creation of FileStream objects.
The CreateText method creates or opens a file for writing UTF-8 encoded text.
The following example demonstrates some of the main members of the File class.

March 31st, 2008 by

daniva

Loading ...
System.IO.DirectoryInfo class exposes instance methods for creating, moving, and enumerating through directories and subdirectories.

March 31st, 2008 by

daniva

Loading ...
Del is a command used to delete files from the computer.

March 31st, 2008 by

daniva

Loading ...
Del is a command used to delete files from the computer.

March 31st, 2008 by

daniva

Loading ...
Del is a command used to delete files from the computer.

March 31st, 2008 by

daniva

Loading ...
Del is a command used to delete files from the computer.

March 31st, 2008 by

daniva

Loading ...
Del is a command used to delete files from the computer.

March 31st, 2008 by

daniva

Loading ...
Del is a command used to delete files from the computer.

March 31st, 2008 by

daniva

Loading ...
This nice function will convert a size string to a size string representation in various units. the ByRef sizes parameter is converted to a Dictionary in the Sub. then a calculation is performed for every unit offsets of 1K.

March 31st, 2008 by

daniva

Loading ...
we have a script that connects to the My Pictures folder and deletes any .txt files it finds there. As for the code itself, we start things off the On Error Resume Next statement. This statement is very important. In order to keep the script simple, we don’t bother verifying whether or not there actually are any .txt files in the My Pictures folder; we just have code that deletes those files. If it turns out that no such files exist, an error will be generated: without the On Error Resume Next statement, that error would cause the script to blow up. With this statement, however, the script simply shrugs its shoulders and keeps going. Next we define a pair of constants:

March 31st, 2008 by

daniva

Loading ...
Begin by setting the value of the constant ReadOnly to 1. We then create an instance of the FileSystemObject, and use the GetFile method to bind to the file filePathStr.

March 31st, 2008 by

daniva

Loading ...
We have function that removes older files than x days in a specific folder.
The two arguments of the function give us the flexibility to choose the folder and the day’s factor argument. The function will return -1, in case of an error, or a number, in case of success. Note that 0 (zero) is also considered a success, zero means that the folder was empty. The return default value of the function is always failed ( -1 ).

March 31st, 2008 by

daniva

Loading ...
the immediately solution is by using a WMI script. Admittedly, we could have achieved the same results by using the FileSystemObject.
We opted to go with WMI for one simple reason: that enables us to run this script against remote computers.

March 31st, 2008 by

daniva

Loading ...
Sometimes we need to rename all the files in a given folder, either by appending the date, changing the file extension.
The following example simulates a backup operation, by renaming all files extensions in the LOG folder from .log to .bak.
The Script assumes that you already have a folder under location C:\LOG and assumes that the folder contains at least 1 xxxx.log file.
Recent Comments