The File System object provides the ability to access a server's file system. You can process folders and files using this object. The full path is required to access the DOS files.
Returns the folder object that contains the server executable (server.exe).
Object.GetServerFolder
Folder object.
Read-only.
This example returns NWserver as the file object as the server executable (server.exe) is located in C:\NWserver.
<% Set FSO = CreateObject("Scripting.FileSystemObject") %>
<% Set Folder = FSO.GetServerFolder %>
<% Response.Write (Folder.Name) %>
Appends a file name to an existing path.
object.BuildPath(
Path As String
Name As String)
String.
This example appends the file name FSO.TXT to the directory specified.
<% Set FSO = CreateObject("Scripting.FileSystemObject")
<% Set FSO = CreateObject("Scripting.FileSystemObject")
’Appends the file fso.txt to the specified directory path
Response.Write "FSO.BuildPath("Sys:\readme","fso.txt") %>
NOTE:The argument in the CreateObject call may also be the UCX:File SystemObject.
Copies a file from one directory to another.
object.CopyFile(
Source As String,
Destination As String [,
OverWrite As Boolean])
Boolean.
CopyFile will fail if the destination directory has read-only attributes set, regardless of the value of the Overwrite parameter.This will work only for NetWare files.
If the Web-based script is not authenticated to eDirectory with appropriate rights, an error is returned.
This example copies TEST1.TXT from Sys:\nsn\user directory to Sys:\nsn\util directory. The file TEST1.TXT file should be existing in the specified directory.
<% Set FSO = CreateObject("Scripting.FileSystemObject") %>
<% ’Copies the file from user to util directory and overwrites
if already existing under util directory
Response.write FSO.CopyFile
("sys:\nsn\user\test1.txt","sys:\nsn\util\",TRUE) %>
Copies a folder from one location to another along with the subdirectories.
object.CopyFolder(
Source As String,
Destination As String [,
OverWrite As Boolean])
Boolean.
CopyFolder will fail if the destination directory has read-only attributes set, regardless of the value of the Overwrite parameter.
If the Web-based script is not authenticated to eDirectory with appropriate rights, an error is returned.
This example copies folder \TEMP from Sys:\nsn\user\ to Sys:\nsn\util\. Ensure that the folder is existing. Else the script will give an error.
<% Set FSO = CreateObject("Scripting.FileSystemObject") %>
<% ’Copies the folder TEMP from user directory to UTIL
directory
Response.Write
FSO.CopyFolder("sys:\nsn\user\temp","sys:\nsn\util\",TRUE)
%>
Creates a folder with the specified name.
object.CreateFolder(
FolderName As String)
Boolean.
If the Web-based script is not authenticated to eDirectory with appropriate rights, an error is returned.
This example creates the folder named \SAMPLE in Sys:\NSN.
<% Set FSO = CreateObject("Scripting.FileSystemObject") %>
<% ’Creates a folder SAMPLE in NSN under Sys:
Response.Write FSO.CreateFolder("sys:\nsn\sample") %>
Creates a specified file name and returns a TextStream object that can be used to read from or write to a file.
object.CreateTextFile(
FileName As String
[, Overwrite As Boolean
[, Unicode As Boolean]])
If the Web-based script is not authenticated to eDirectory with appropriate rights, an error is returned.
This example creates or overwrites an ASCII text file named TEST.TXT and returns a TextStream object.
<% Set FSO = CreateObject("Scripting.FileSystemObject")
’Creates a text file
Set TextStream =FSO.CreatetextFile("sys:\nsn\user\test.txt")
’Checks whether the file pointer is at the end of the line
Response.Write TextStream.AtEndOfLine
Textstream.Close() %>
Deletes a specified file.
object.DeleteFile(
FileSpec As String,
[,Force As Boolean])
Boolean.
The Force parameter will work only for NetWare files.
If the Web-based script is not authenticated to eDirectory with appropriate rights, an error is returned.
This example deletes TEST1.TXT, which has Read-only attributes.
<% Set FSO = CreateObject("Scripting.FileSystemObject") %>
<% ’Deletes the file from util directory
Response.write FSO.DeleteFile("Sys:\nsn\util\test1.txt",TRUE) %>
Deletes a specified folder along with the subdirectories and their content.
object.DeleteFolder(
FolderSpec As String
[, Force As Boolean])
Boolean.
If the Web-based script is not authenticated to eDirectory with appropriate rights, an error is returned.
This example deletes the folder \SAMPLE.
<% Set FSO = CreateObject("Scripting.FileSystemObject")
response.Write FSO.DeleteFolder("Sys:\nsn\sample", TRUE) %>
Returns TRUE if a specified file exists.
object.FileExist(
FileSpec As String)
Boolean.
This example returns TRUE if the file named FILE1.BAS exists in Sys:\nsn\user directory.
<% Set FSO = CreateObject("Scripting.FileSystemObject")
’Returns FALSE as the specified file does not exist
Response.Write FSO.FileExists("sys:\nsn\user\file1.bas") %>
Returns TRUE if a specified folder exists.
object.FolderExist(
FolderSpec As String)
Boolean.
This example returns TRUE, if the directory named \TEMP exists under Sys:\nsn\user directory.
<% Set FSO = CreateObject("Scripting.FileSystemObject")
’Returns TRUE if the specified folder exists
Response.Write FSO.FolderExists("sys:\nsn\user\Temp") %>
Returns a complete path from the path details specified.
object.GetAbsolutePathName (
PathSpec As String)
String.
This example gets the complete path of the folder \USER.
<% Set FSO = CreateObject("Scripting.FileSystemObject")
’Returns the absolute path name of the USER directory
Response.Write FSO.GetAbsolutePathName("\user") %>
Returns a string containing the base name of the file (without the extension), or folder in the path specified.
object.GetBaseName(
Path As String)
String.
This example returns Test, which is the base name of the file TEST.TXT.
<% Set FSO = CreateObject("Scripting.FileSystemObject")
’Returns the Base name of the file TEST.TXT
Response.Write FSO.GetBaseName("Sys:\nsn\user\test.txt") %>
Returns a string containing the extension name of the last component in a path.
object.GetExtensionName(
Path As String)
String.
This example returns the value "TXT", which is the extension of the file TEST.TXT.
<% Set FSO = CreateObject("Scripting.FileSystemObject")
’Returns the extension name of the file TEST.TXT
Response.Write
FSO.GetExtensionName("Sys:\nsn\user\test.txt") %>>
Returns a file object corresponding to the files specified in the path.
object.GetFile(
FileSpec As String)
See sample in Example.
Returns a string containing the file name from the specified path.
object.GetFileName(
PathSpec As String)
String.
This example returns the TEST.TXT.
<% Set FSO = CreateObject("Scripting.FileSystemObject")
’Returns the file name of the file TEST.TXT
Response.Write FSO.GetFileName("Sys:\nsn\user\test.txt") %>
Returns a folder object corresponding to the folder in the specified path.
object.GetFolder
FolderSpec As String)
Folder.
See sample in Example.
Returns a string containing the name of the parent folder or file in the specified path.
object.GetParentFolderName(
Path As String)
String.
This example returns NSN, which is the parent of \USER.
<% Set FSO = CreateObject("Scripting.FileSystemObject")
’Returns name of the parent folder
Response.Write FSO.GetParentFolderName("Sys:\nsn\user") %>
Returns a randomly generated temporary file or folder name that is useful for performing operations that require a temporary file or folder.
object.GetTempName
None.
String.
This example returns the temp name of a file or folder.
<% Set FSO = CreateObject("Scripting.FileSystemObject")
’Returns the randomly generated temporary file
Response.Write FSO.GetTempName %>
Moves a file from one location to another.
object.MoveFile( Source As String, Destination As String)
Boolean.
If the Web-based script is not authenticated to eDirectory with appropriate rights, an error is returned.
This example moves TEST1.TXT from Sys:\nsn\user to Sys:\nsn\util directory.
<% Set FSO = CreateObject("Scripting.FileSystemObject")
’Moves the file TEST1.TXT from USER to UTIL directory
Response.Write
FSO.MoveFile("sys:\nsn\user\test1.txt","sys:\nsn\util\") %>
Moves one or more folders from one location to another.
object.MoveFolder( Source As String, Destination As String)
Boolean.
If the Web-based script is not authenticated to eDirectory with appropriate rights, an error is returned.
This example moves \NSN\USER\TEMP to \NSN\UTIL and the resultant path would be SYS:\NSN\UTIL.
<% Set FSO = CreateObject("Scripting.FileSystemObject")
’Moves the folder TEMP from USER to UTIL directory
Response.Write
FSO.MoveFolder("sys:\nsn\user\temp","sys:\nsn\util\") %>
Opens a specified file and returns a TextStream object that can be used to read from, write to, or append to the file.
object.OpenTextFile
(FileName As String [,
I/OMode As Integer [,
Create As Boolean [,
Format As Integer]]])
File Open Constants.
File Open Constants.
If the Web-based script is not authenticated to eDirectory with appropriate rights, an error is returned.