Knowledge Base Article

Home Page > Knowledge Base > Rapise

Article Accessing Files and I/O functions using Rapise

by Adam S on Monday, October 21, 2013

Sometimes using Rapise you need to access files on the Windows filesystem, either for testing purposes, or to object test data stored in a flat CSV, TSV or text file. This sample illustrates how you can access the File System using Rapise and the Windows FileSystemObject (

The following sample code illustrates how to access files using Rapise:

function Test()
    //IOMode constants
    var IOMode_ForReading = 1;
    var IOMode_ForWriting = 2;
    var IOMode_ForAppending = 8;

    //var Format constants
    var IOFormat_ASCII = 0;
    var IOFormat_Unicode = -1;

    //This sample demonstrates how to manipulate the Windows file system using Rapise
    //We shall open a text file for writing in this simple example

    var fso = new ActiveXObject('Scripting.FileSystemObject');
    var ts = fso.CreateTextFile('C:\\Temp\\MyTestFile.txt');

    var file = fso.GetFile('C:\\Temp\\MyTestFile.txt');
    ts = file.OpenAsTextStream(IOMode_ForWriting, IOFormat_Unicode);
    ts.WriteLine('Hello World!');
    Tester.Message('Wrote File');

    //Now read this file back
    file = fso.GetFile('C:\\Temp\\MyTestFile.txt');
    ts = file.OpenAsTextStream(IOMode_ForReading, IOFormat_Unicode);
    var text = ts.ReadLine();

Article Info
Last Updated: 10/21/2013
Article ID: KB62
# Views: 3096
Powered by KronoDesk v1.1.0.15 | © Copyright Inflectra Corporation 2011-2016 | Licensed to Inflectra Corporation.