JavaScript Tutorial/MS JScript/FileSystemObject — различия между версиями

Материал из Web эксперт
Перейти к: навигация, поиск
 
м (1 версия)
 
(нет различий)

Текущая версия на 08:24, 26 мая 2010

FileSystemObject

The FileSystemObject object provides access to the computer"s file system.

Properties and Methods of the FileSystemObject Object

Property/Method Description BuildPath() Appends information to a file path CopyFile() Copies a file from one location to another CopyFolder() Copies a folder from one location to another CreateFolder() Creates a new folder object CreateTextfile() Creates a new text file object DeleteFile() Removes a file DeleteFolder() Removes a folder object DriveExists() Determines whether a drive exists Drives Returns a Drives collection, containing all the available drive objects FileExists() Determines whether a file exists FolderExists() Determines whether a folder exists GetAbsolutePathName() Returns the absolute pathname for a file GetBaseName() Gets the base name of the last component GetDrive() Gets the drive letter for a file GetDriveName() Gets the drive name on which a file resides ExtensionName() Returns the extension for a file GetFile() Gets the file object GetFileName() Gets the name of a file GetFolder() Gets the folder name that contains a file GetParentFolderName() Gets the parent folder"s name GetSpecialFolder() Gets the folder names for special folders GetTempName() Creates a randomly generated temporary file MoveFile() Moves a file from one location to another MoveFolder() Moves a folder and its contents from one location to another OpentextFile() Opens a text file stream to a file



<html>
    <body>
    <script language="JScript">
    <!--
       var myObject;
       myObject = new ActiveXObject("Scripting.FileSystemObject");
    -->
    </script>
    </body>
    </html>


FileSystemObject.BuildPath()

Syntax



filesystemobject.BuildPath(path, name)


FileSystemObject.CopyFile()

Syntax



filesystemobject.CopyFile(source, destination, overwrite)


FileSystemObject.CopyFolder()

Syntax



filesystemobject.CopyFolder(source, destination, overwrite)


FileSystemObject.CreateFolder()

Syntax



filesystemobject.CreateFolder(name)


FileSystemObject.CreateTextFile()

filesystemobject.CreateTextFile(filename, overwrite)


FileSystemObject.DeleteFile()

Syntax



filesystemobject.DeleteFile(filename, force)


FileSystemObject.DeleteFolder()

Syntax



filesystemobject.DeleteFolder(foldername, force)


FileSystemObject.DriveExists()

Syntax



filesystemobject.DriveExists(letter)


FileSystemObject.Drives

Syntax



filesystemobject.Drives


FileSystemObject.FileExists()

Syntax



filesystemobject.FileExists(filename)


FileSystemObject.FolderExists()

Syntax:



filesystemobject.FolderExists(foldername)


FileSystemObject.GetAbsolutePathName()

Syntax



filesystemobject.GetAbsolutePathName(/Pathname/)


FileSystemObject.GetBaseName()

Syntax



filesystemobject.GetBaseName(path)


FileSystemObject.GetDrive()

Syntax



filesystemobject.GetDrive(drive)


FileSystemObject.GetDriveName()

Syntax



filesystemobject.GetDriveName(letter)


FileSystemObject.GetExtensionName()

Syntax



filesystemobject.GetExtensionName(path)


FileSystemObject.GetFile()

Syntax



filesystemobject.GetFile(/file name/)


FileSystemObject.GetFileName()

Syntax



filesystemobject.GetFileName(filename)


FileSystemObject.GetFolder()

Syntax



filesystemobject.GetFolder(/Path/)


FileSystemObject.GetParentFolderName()

Syntax



filesystemobject.GetParentFolderName(foldername)


FileSystemObject.GetSpecialFolder()

Syntax



filesystemobject.GetSpecialFolder(num)


The GetSpecialFolder() method gets the special folder object specified.

This method takes num as its only parameter, which represents one of the following values:

0 Windows folder 1 System folder 2 Temporary folder

FileSystemObject.GetTempName()

The GetTempName() method gets a randomly generated temporary file or folder.



<html>
    <body>
    <script language="JScript">
    <!--
    function get()
    {
        var myObject, name;
        myObject = new ActiveXObject("Scripting.FileSystemObject");
        name = myObject.GetTempName();
        alert("The temp file name is: " + name);
    }
    -->
    </script>
    Get a temp file.
    <form name="myForm">
    <input type="Button" value="Get Temp Name" onClick="get()">
    </form>
    </body>
    </html>


FileSystemObject.MoveFile()

Syntax



filesystemobject.MoveFile(source, destination)


FileSystemObject.MoveFolder()

Syntax



filesystemobject.MoveFolder(/arguments/)


FileSystemObject.OpentextFile()

Syntax



filesystemobject.OpentextFile(filename, iomode, create, format)