VBScript: trabajando con ficheros (II)
Microsoft proporciona mediante FSO una herramienta para trabajar con carpetas y ficheros.
Microsoft se refiere a FileSystemObject como a un "Object Model", esto puede entenderse como sinónimo de clase. Así, FSO es una clase mediante la cual se puede trabajar con ficheros y carpetas. Esta clase está en la librería de nombre "Scripting", que está en la dll: Scrrun.dll.
En la sesión anterior abrimos un fichero para leer su contenido y recorrimos su contenido línea a línea.
En la siguiente dirección hay una lista de los métodos que proporciona esta clase:
http://msdn.microsoft.com/en-us/library/aa711216(VS.71).aspx
y aquí está la lista, cada nombre de función es un link a una página con una explicación detallada con un ejemplo:
BuildPath Method This method is used to append a name onto an existing path. [newfullpath = ]object.BuildPath(path, name) CopyFile Method This method allows us to copy one or more files from one location (the source) to another (destination). Syntax: object.CopyFile source, destination [, overwrite] CopyFolder Method Copies one or more folders and all contents, including files and subfolders, from one location to another. Syntax: object.CopyFolder source, destination, [, overwrite] CreateFolder Method This method allows us to create a folder. Syntax: object.CreateFolderfoldername CreateTextFile Method Creates a text file and returns a TextStreamObject that can then be used to write to and read from the file. Syntax: object.CreateTextFile filename [, overwrite[, unicode]] DeleteFile Method This method deletes a specified file or files (using wilcards). Syntax: object.DeleteFile file [, force] DeleteFolder Method This method deletes a specified folder, including all files and subfolders. Syntax: object.DeleteFolder folder [, force] DriveExists Method This method lets us check if a specified drive exists. It returns True if the drive does exist and False if it doesn't. Syntax: object.DriveExists(drive) FileExists Method Lets us check whether a specified file exists. Returns True if the file does exist and False otherwise. Syntax: object.FileExists(file) FolderExists Method Allows us to check if a specified folder exists. Returns True if the folder does exist and False if it doesn't. Syntax: object.FolderExists(folder) GetAbsolutePathName Method This method gets the complete path from the root of the drive for the specified path string. Syntax: object.GetAbsolutePathName(path) GetBaseName Method This method gets the base name of the file or folder in a specified path. Syntax: object.GetBaseName(path) GetDrive Method This method returns a Drive object corresponding to the drive in a supplied path. Syntax: object.GetDrive(drive) GetDriveName Method This method gets a string containing the name of the drive in a supplied path. Syntax: object.GetDriveName(path) GetExtensionName Method Used to return a string containing the extension name of the last component in a supplied path. Syntax: object.GetExtensionName(path) GetFile Method Returns the File object for the specified file name. Syntax: object.GetFile(filename) GetFileName Method This method is used to return the name of the last file or folder of the supplied path. Syntax: object.GetFileName(path) GetFileVersion Method This method is used to return the version of the file in the specified path. Syntax: object.GetFileVersion(path) GetFolder Method This method returns a Folder object of the folder specified in the folder parameter. Syntax: object.GetFolder(folder) GetParentFolderName Method Returns a string containing the name of the parent folder of the last file or folder in a specified path. Syntax: object.GetParentFolderName(path) GetSpecialFolder Method Returns the path to one of the special folders - \Windows, \System or \TMP. Syntax: object.GetSpecialFolder(folder) GetTempName Method This method is used to generate a random filename for a temporary file.. Syntax: object.GetTempName MoveFile Method Moves one or more files from one location to another. Syntax: object.MoveFile source, destination MoveFolder Method Moves one or more folders from one location to another. Syntax: object.MoveFolder source, destination OpenTextFile Method Opens the file specified in the filename parameter and returns an instance of the TextStreamObject for that file. Syntax: object.OpenTextFile(filename [, iomode[, create[, format]]]) |
No comments:
Post a Comment