spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column71


Scripting the File System, Part I

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

Build() through CreateFolder()

BuildPath(path, name)String

This method appends a name to a given path. A delimiter is added automatically. The following script will pop up the alert window below:

<SCRIPT LANGUAGE="JavaScript">
<!--
var fso = new ActiveXObject("Scripting.FileSystemObject");
var newpath = fso.BuildPath("c:\\tmp", "kuku.txt");
alert(newpath);
-->
</SCRIPT>

CopyFile(source, destination, overwriteFlag)Undefined

This method copies a source file to a destination file. If the destination file exists, it is overwritten only when overwriteFlag is true. On some systems, the destination file cannot be overwritten no matter what. Here is a script that copies test.txt from f:\ to f:\yehuda:

<SCRIPT LANGUAGE="JavaScript">
<!--
var fso = new ActiveXObject("Scripting.FileSystemObject");
var newpath = fso.CopyFile("f:\\test.txt", "f:\\yehuda\\test.txt");
-->
</SCRIPT>

CopyFolder(source, destination, overwriteFlag)Undefined

This method copies a source folder to a destination folder. If the destination folder exists, it is overwritten only when overwriteFlag is true. On some systems, the destination folder cannot be overwritten no matter what. Here is a script that copies temp from f:\ to f:\yehuda:

<SCRIPT LANGUAGE="JavaScript">
<!--
var fso = new ActiveXObject("Scripting.FileSystemObject");
fso.CopyFolder("f:\\temp", "f:\\yehuda\\temp");
-->
</SCRIPT>

CreateFolder(folderName)String

This method creates a folder called folderName. It returns the folder name. Here is a script that creates a folder new:

<SCRIPT LANGUAGE="JavaScript">
<!--
var fso = new ActiveXObject("Scripting.FileSystemObject");
var newFolderName = fso.CreateFolder("f:\\new");
-->
</SCRIPT>

Next: How to use CreateTextFile() through DriveExists()

http://www.internet.com

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: November 20, 2000
Revised: November 20, 2000

URL: http://www.webreference.com/js/column71/3.html