Moving, Copying, And Deleting Files And Folders; Moving And Copying Files - Adobe GoLive CS2 Programmer's Manual

Hide thumbs Also See for GoLive CS2:
Table of Contents

Advertisement

SDK Programmer's Guide
file = JSXFile ("Main.html");
Specifying the path as a URL allows you to avoid dealing with most platform-specific file-naming
conventions. You need not construct different versions of the same pathname using platform-specific
separator characters. For example:
// specify path as URL to run the same code on Mac OS or Windows
file = new JSXFile ("file://d:/GoLive/Main.html");
The SDK always treats forward slash ( / ) characters as URL delimiters. Paths that mix forward slashes with
other delimiters may confuse the SDK code that converts platform-specific pathnames to and from URL
format; for example, "Macintosh HD:07/18/2000:data" .
You cannot use platform-specific illegal characters in any pathname, even if the path is specified as a URL.
For example, pathnames containing non-printing characters are never valid, regardless of the file-naming
conventions used.

Moving, Copying, and Deleting Files and Folders

Be cautious when manipulating the file system programmatically.
Renaming or moving files that are open can have serious adverse consequences.
In particular, moving or renaming a currently installed extension while GoLive is running can cause the
extension or GoLive to terminate abnormally. You can disable an extension temporarily without
moving it out of the Extend Scripts folder; see
GoLive for the change to take effect.
The remove method of the file object deletes the referenced file or folder immediately, without
moving it to the system trash. The effects of the remove method cannot be undone. It is recommended
that you prompt the user for permission to delete a file or folder before actually deleting it.

Moving and copying files

Before moving or copying a file, check that it exists, and is a file rather than a folder. The destination folder
must also exist. For an example of this kind of checking, see
Sites. If an item with the same name as the file being moved or copied exists in the destination directory,
the operation fails.
To move a file, call the move method of its file object. To copy it, use the copy method. For either of
these methods, you can specify the new location as a pathname or as a local URL, ending with the
filename of the file. This example moves the myGraphic file into the myPixFolder folder:
var myGraphic = new JSXFile("C:\myRoot\myFile.html");
if (myGraphic.exists && !myGraphic.isFile)
{
if !(myGraphic.move ("C:\myRoot\myPixFolder\myFile.html"))
{
}
}
You cannot use the move or copy method to transfer files to HTTP server volumes. To upload files or
folders to a web server volume, use the file object's put method; see
Window.alert ("Sorry, could not move the file");
Adobe GoLive CS2 SDK
Enabling and disabling
Managing Files and Folders
modules. You must restart
Copying files
in
Chapter 10, "Managing Web
Using HTTP
127
protocol.

Advertisement

Table of Contents
loading

Table of Contents