FileSystemObject Methods
The FileSystemObject object contains the following methods:
BlobExists
The BlobExists method checks to see if the Blob exists.
Syntax
BlobExists(BlobPath As String) As Boolean
Parameters
| Parameter | Required | Description |
|---|---|---|
|
BlobPath |
Yes |
A valid Blob file path, in "site.service\folder\file" format. |
CanReadBlobFile
The CanReadBlobFile method checks all the various security settings associated with the Blob file and returns true if the ambient user can read the file, or returns false if the ambient user cannot read the file. See Blob Component-Level Security for more information.
Syntax
CanReadBlobFile(ByVal BlobPath As String) As Boolean
Parameters
| Parameter | Required | Description |
|---|---|---|
|
BlobPath |
Yes |
A valid Blob file path, in "site.service\folder\file" format. |
Remarks
Return Value: True if the ambient user can read the Blob file, False if otherwise.
Example
The following method checks whether the ambient user can read the Blob file.
Sub ReadBlobFileSample()
On Error Resume Next
Dim cygFileSystemObj
Set cygFileSystemObj = CreateObject("CxScript.FileSystemObject")
Dim pathList
pathList = cygFileSystemObj.GetBlobPathList("CYGNET.BSS")
Dim path
For Each path In pathList
WScript.Echo "Processing blob path '" & path & "'"
Dim bRet
WScript.Echo " GetBlobFileSecurityChain returned chain of '" & strChain & "'"
If cygFileSystemObj.CanReadBlobFile(path) Then
WScript.Echo " CanReadBlobFile returned 'true'. Attempting to download..."
bRet = cygFileSystemObj.DownloadFromBlobPathToDirectory(path, ".\", 0)
If err.number <> 0 Then
WScript.Echo " Download threw error(" & err.number & "): " & err.Description
Else
WScript.Echo " Download returned '" & bRet & "'"
End If
Else
WScript.Echo " CanReadBlobFile returned 'false'. Attempting to download anyway..."
bRet = cygFileSystemObj.DownloadFromBlobPathToDirectory(path, ".\", 0)
If err.number <> 0 Then
WScript.Echo " Download threw error(" & err.number & "): " & err.Description
Else
WScript.Echo " Download returned '" & bRet & "'"
End If
End If
err.Clear
Next
End Sub
CheckInBlobFile
The CheckInBlobFile method checks in the specified Blob file.
Syntax
CheckInBlobFile(BlobPath As String) As Boolean
Parameters
| Parameter | Required | Description |
|---|---|---|
|
BlobPath |
Yes |
A valid Blob file path, in "site.service\folder\file" format. |
CheckOutBlobFile
The CheckOutBlobFile method checks out the specified Blob file.
Syntax
CheckOutBlobFile(BlobPath As String) As Boolean
Parameters
| Parameter | Required | Description |
|---|---|---|
|
BlobPath |
Yes |
A valid Blob file path, in "site.service\folder\file" format. |
DeleteFileFromBlob
The DeleteFileFromBlob method deletes the file from the specified Blob path.
Syntax
DeleteFileFromBlob(BlobPath As String) As Boolean
Parameters
| Parameter | Required | Description |
|---|---|---|
|
BlobPath |
Yes |
A valid Blob file path, in "site.service\folder\file" format. |
Remarks
Return Value: True if the delete was successful, False if it was not.
Errors: If BlobPath is invalid, an error will display.
Example
The following method deletes test.csw from CYGDEMO.BSS and alerts the user.
Sub deleteFile()
Dim objFileSystem
Set objFileSystem = CreateObject("CxScript.FileSystemObject")
objFileSystem.DeleteFileFromBlob("CYGDEMO.BSS\TEST\test.CSW")
edtMessageBox.Text = "File Deleted"
End Sub
DownloadBlobFile
The DownloadBlobFile method downloads the specified file from the specified Blob service to the current working directory.
Syntax
DownloadBlobFile(BlobSiteService As String, BlobFolder As String, FileName As String, UpdateRulesMask As Integer) As Boolean
Parameters
| Parameter | Required | Description |
|---|---|---|
|
BlobSiteService |
Yes |
A valid service name, in "site.service" format. |
|
BlobFolder |
Yes |
A valid foldername in BlobSiteService. |
|
FileName |
Yes |
A valid file name in BlobApplication. |
|
UpdateRulesMask |
Yes |
Used to determine whether the file will be uploaded or downloaded. Set to 1 to update the rules mask, or 0 to leave it as is. See UpdateRulesMask for more information about this parameter. |
Remarks
The file will be downloaded to the current working directory. This depends on what is actually running the script. If you are running the script in CygNet Studio, then that will be the CygNet Studio directory. If the script is running in the HSS, then the HSS folder will be the download location. Likewise, if you are running the script from the command line, then it will download the file to the current directory.
Return Value: True if the download was successful, False if it was not.
Errors: If BlobSiteService, BlobFolder, or FileName are invalid, an error will display.
Example
The following example downloads MeterTest.csf, and tells the user if it was successful or not.
Sub downloadFile()
Dim objFileSystem
Set objFileSystem = CreateObject("CxScript.FileSystemObject")
Dim bRet
bRet = objFileSystem.DownloadBlobFile("CYGDEMO.BSS", "TEST", "MeterTest.csf", 0)
If bRet Then
edtMessageBox.Text = "File downloaded successfully"
Else
edtMessageBox.Text = "Error downloading file"
End If
End Sub
DownloadBlobFileToDirectory
The DownloadBlobFileToDirectory method downloads the specified file from a Blob service to the destination directory.
Syntax
DownloadBlobFileToDirectory(BlobSiteService As String, BlobFolder As String, FileName As String, DestinationDir As String, UpdateRulesMask As Integer) As Boolean
Parameters
| Parameter | Required | Description |
|---|---|---|
|
BlobSiteService |
Yes |
A valid service name, in "site.service" format. |
|
BlobFolder |
Yes |
A valid foldername in BlobSiteService. |
|
FileName |
Yes |
A valid file name in BlobApplication. |
|
DestinationDir |
Yes |
The local file path to download the file to. |
|
UpdateRulesMask |
Yes |
Used to determine whether the file will be uploaded or downloaded. Set to 1 to update the rules mask, or 0 to leave it as is. See UpdateRulesMask for more information about this parameter. |
Remarks
If DestinationDir does not already exist, its path will be created.
Return Value: True if the download was successful, False if it was not.
Errors: If BlobSiteService, BlobFolder, or FileName are invalid, an error will display.
Example
The following example downloads MeterTest.csf to C:\MyFolder and tells the user if it was successful or not.
Sub downloadFileToDir()
Dim objFileSystem
Set objFileSystem = CreateObject("CxScript.FileSystemObject")
Dim bRet
bRet = objFileSystem.DownloadBlobFileToDirectory("CYGDEMO.BSS", _
"TEST", "MeterTest.csf", "C:\MyFolder", 0)
If bRet Then
edtMessageBox.Text = "File downloaded successfully"
Else
edtMessageBox.Text = "Error downloading file"
End If
End Sub
DownloadFromBlobPath
The DownloadFromBlobPath method downloads the specified file from a Blob service to the current working directory.
Syntax
DownloadFromBlobPath(BlobPath As String, UpdateRulesMask As Integer) As Boolean
Parameters
| Parameter | Required | Description |
|---|---|---|
|
BlobPath |
Yes |
A valid Blob file path, in "site.service\folder\file" format. |
|
UpdateRulesMask |
Yes |
Used to determine whether the file will be uploaded or downloaded. Set to 1 to update the rules mask, or 0 to leave it as is. See UpdateRulesMask for more information about this parameter. |
Remarks
The file will be downloaded to the current working directory. This depends on what is actually running the script. If you are running the script in CygNet Studio, then that will be the CygNet Studio directory. If the script is running in the HSS, then the HSS folder will be the download location. Likewise, if you are running the script from the command line, then it will download the file to the current directory.
Return Value: True if the download was successful, False if it was not.
Errors: If BlobPath is invalid, an error will display.
Example
The following example downloads MeterTest.csf using its Blob path and tells the user if it was successful or not.
Sub downloadFilePath()
Dim objFileSystem
Set objFileSystem = CreateObject("CxScript.FileSystemObject")
Dim bRet
bRet = objFileSystem.DownloadFromBlobPath("CYGDEMO.BSS\TEST\MeterTest.csf", 0)
If bRet Then
edtMessageBox.Text = "File downloaded successfully"
Else
edtMessageBox.Text = "Error downloading file"
End If
End Sub
DownloadFromBlobPathToDirectory
The DownloadFromBlobPathToDirectory method downloads the specified file from a Blob service to the destination directory.
Syntax
DownloadFromBlobPathToDirectory(BlobPath As String, DestinationDir As String, UpdateRulesMask As Integer) As Boolean
Parameters
| Parameter | Required | Description |
|---|---|---|
|
BlobPath |
Yes |
A valid Blob file path, in "site.service\folder\file" format. |
|
DestinationDir |
Yes |
The local file path to download the file to. |
|
UpdateRulesMask |
Yes |
Used to determine whether the file will be uploaded or downloaded. Set to 1 to update the rules mask, or 0 to leave it as is. See UpdateRulesMask for more information about this parameter. |
Remarks
If DestinationDir does not already exist, its path will be created.
Return Value: True if the download was successful, False if it was not.
Errors: If BlobPath is invalid, an error will display.
Example
The following example downloads MeterTest.csf using its Blob path to C:\MyFolder and tells the user if it was successful or not.
Sub downloadFilePathToDir()
Dim objFileSystem
Set objFileSystem = CreateObject("CxScript.FileSystemObject")
Dim bRet
bRet = objFileSystem.DownloadFromBlobPathToDirectory( _
"CYGDEMO.BSS\TEST\MeterTest.csf", "C:\MyFolder", 0)
If bRet Then
edtMessageBox.Text = "File downloaded successfully"
Else
edtMessageBox.Text = "Error downloading file"
End If
End Sub
EnableLibrarian
The EnableLibrarian method enables or disables the librarian state of the specified Blob folder. Also see IsLibrarianEnabled.
Syntax
EnableLibrarian(BlobSiteService As String, Folder As String, Enable As Boolean) As Boolean
Parameters
| Parameter | Required | Description |
|---|---|---|
|
BlobSiteService |
Yes |
A valid service name, in "site.service" format. |
|
Folder |
Yes |
A valid folder name in BlobSiteService. |
|
Enable |
Yes |
A Boolean value indicating whether or not to enable librarian state for the specified Blob folder. |
GetBlobFileCheckOutDetails
The GetBlobFileCheckOutDetails method retrieves check out status details for the specified Blob file as a 2-D array.
Syntax
GetBlobFileCheckOutDetails(BlobPath As String, DetailsArray) As Boolean
Parameters
| Parameter | Required | Description |
|---|---|---|
|
BlobPath |
Yes |
A valid Blob file path, in "site.service\folder\file" format. |
|
DetailsArray |
Yes |
An array of check out status details for the Blob file. |
GetBlobFileSecurityChain
The GetBlobFileSecurityChain method returns the Blob file security chain in the following form:
<ACSDomainSiteService>;<Default BSS APP+EVT>;<BSS Folder APP+EVT>;<BSS File APP+EVT>
The method queries the active ambient Domain Id, the associated Site.Service, the associated security application and event (DBS_MAIN_SEC_EVENT ACS_APPLICATION) defined for the BSS.
The intended use of the blob file security chain is to reduce the number of redundant calls that check if a specific user has access to multiple blob files, all of which are configured with identical ACS permissions.
See Blob Component-Level Security for more information.
Syntax
GetBlobFileSecurityChain(ByVal BlobPath As String) As String
Parameters
| Parameter | Required | Description |
|---|---|---|
|
BlobPath |
Yes |
A valid Blob file path, in "site.service\folder\file" format. |
Example
The following example fills up a dictionary with the unique blob file security chains for all blob files in a BSS and associates each with a Boolean value, 'true' if the current user has read access to the security chain, 'false' otherwise. The contents of this dictionary can then be used to efficiently determine if the user has read access to a blob file based on that file’s blob file security chain.
Dim dictionaryBlobSecChainToReadAccess
Set dictionaryBlobSecChainToReadAccess = CreateObject("CxScript.Dictionary")
Sub BlobFileSecurityChainSample(dictionaryBlobSecChainToReadAccess)
Dim cygFileSystemObj
Set cygFileSystemObj = CreateObject("CxScript.FileSystemObject")
Dim pathList
pathList = cygFileSystemObj.GetBlobPathList("CYGNET.BSS")
Dim path
For Each path In pathList
WScript.Echo "Processing blob path '" & path & "'"
Dim bRet
dim strChain
strChain = cygFileSystemObj.GetBlobFileSecurityChain(path)
WScript.Echo " GetBlobFileSecurityChain returned chain of '" & strChain & "'"
If Not dictionaryBlobSecChainToReadAccess.KeyExists(strChain) then
Dim bCanRead
bCanRead = cygFileSystemObj.CanReadBlobFile(path)
Call dictionaryBlobSecChainToReadAccess.SetKeyValue(strChain, bCanRead)
End if
Next
Dim keys
keys = dictionaryBlobSecChainToReadAccess.GetKeyList()
WScript.Echo "Unique SecurityChain count: " & UBound(keys)+1
Dim strKey
For Each strKey In keys
WScript.Echo " SecurityChain: '" & strKey & "', ReadAccess: '" & dictionaryBlobSecChainToReadAccess.FindValue(strKey) & "'"
Next
End Sub
GetBlobFolderList
The GetBlobFolderList method retrieves a list of all folders for the specified Blob service.
Syntax
GetBlobFolderList(BlobSiteService As String)
Parameters
| Parameter | Required | Description |
|---|---|---|
|
BlobSiteService |
Yes |
A valid service name, in "site.service" format. |
Remarks
Return Value: An array of folders in BlobSiteService. If BlobSiteService is invalid, an empty array will be returned.
Example
The following example gets all the foldersin CYGDEMO.APPS and displays them in a list box.
Sub getBlobFolderList()
Dim objFileSystem
Set objFileSystem = CreateObject("CxScript.FileSystemObject")
Dim arrPathList, item
arrPathList = objFileSystem.GetBlobFolderList("CYGDEMO.APPS")
lstBlob.ResetContent
For Each item In arrPathList
lstBlob.AddString(item)
Next
End Sub
GetBlobFileListByFolder
The GetBlobFileListByFolder method retrieves a list of all file names in the specified Blob folder.
Syntax
GetBlobFileListByFolder(BlobSiteService As String, Folder As String)
Parameters
| Parameter | Required | Description |
|---|---|---|
|
BlobSiteService |
Yes |
A valid service name, in "site.service" format. |
|
Folder |
Yes |
A valid folder name in BlobSiteService. |
Remarks
Return Value: An array of names for all Blob files in the folder. If BlobSiteService or Folder is invalid, an empty array will be returned.
Example
The following example gets all files in the HELP folderand displays them in a list box.
Sub getBlobByFolder()
Dim objFileSystem
Set objFileSystem = CreateObject("CxScript.FileSystemObject")
Dim arrPathList, item
arrPathList = objFileSystem.GetBlobFileListByFolder("CYGDEMO.APPS", "HELP")
lstBlob.ResetContent
For Each item In arrPathList
lstBlob.AddString(item)
Next
End Sub
GetBlobPathList
The GetBlobPathList method retrieves a list of all Blob file paths in the specified Blob service.
Syntax
GetBlobPathList(BlobSiteService As String)
Parameters
| Parameter | Required | Description |
|---|---|---|
|
BlobSiteService |
Yes |
A valid service name, in "site.service" format. |
Remarks
Return Value: An array of file paths for all Blob files in the service. If BlobSiteService is invalid, an empty array will be returned.
Example
The following example gets the file paths for CYGDEMO.BSS and displays them in a list box.
Sub getBlobPaths()
Dim objFileSystem
Set objFileSystem = CreateObject("CxScript.FileSystemObject")
Dim arrPathList, item
arrPathList = objFileSystem.GetBlobPathList("CYGDEMO.BSS")
lstBlob.ResetContent
For Each item In arrPathList
lstBlob.AddString(item)
Next
End Sub
IsBlobFileCheckedOut
The IsBlobFileCheckedOut method checks if the specified Blob file is checked out.
Syntax
IsBlobFileCheckedOutByAnotherUser(BlobPath As String) As Boolean
Parameters
| Parameter | Required | Description |
|---|---|---|
|
BlobPath |
Yes |
A valid Blob file path, in "site.service\folder\file" format. |
IsBlobFileCheckedOutByAnotherUser
The IsBlobFileCheckedOutByAnotherUser method checks if the specified Blob file is checked out by another user.
Syntax
IsBlobFileCheckedOutByAnotherUser(BlobPath As String) As Boolean
Parameters
| Parameter | Required | Description |
|---|---|---|
|
BlobPath |
Yes |
A valid Blob file path, in "site.service\folder\file" format. |
IsBlobFileCheckedOutByCurrentUser
The IsBlobFileCheckedOutByCurrentUser method checks if the specified Blob file is checked out by the current user.
Syntax
IsBlobFileCheckedOutByCurrentUser(BlobPath As String) As Boolean
Parameters
| Parameter | Required | Description |
|---|---|---|
|
BlobPath |
Yes |
A valid Blob file path, in "site.service\folder\file" format. |
IsLibrarianEnabled
The IsLibrarianEnabled method returns the librarian enabled state of the specified Blob folder. See also EnableLibrarian.
Syntax
IsLibrarianEnabled(BlobSiteService As String, Folder As String) As Boolean
Parameters
| Parameter | Required | Description |
|---|---|---|
|
BlobSiteService |
Yes |
A valid service name, in "site.service" format. |
|
Folder |
Yes |
A valid folder name in BlobSiteService. |
IsValidBlobPath
The IsValidBlobPath checks if the format for the Blob path is valid.
Syntax
IsValidBlobPath(BlobPath As String) As Boolean
Parameters
| Parameter | Required | Description |
|---|---|---|
|
BlobPath |
Yes |
A valid Blob file path, in "site.service\folder\file" format. |
ReadBlobString
The ReadBlobString method reads the contents of the specified Blob file to the provided string. Optionally, you can include a Blob file in a BSS on a different domain.
Syntax
ReadBlobString(BlobPath As String) As String
Parameters
| Parameter | Required | Description |
|---|---|---|
|
BlobPath |
Yes |
A valid Blob file path, in "site.service\folder\file" format. |
You can specify a domain for a BSS on another domain, as necessary: "[10003]site.service\folder\file"
Remarks
Return Value: A string containing the contents of the file.
Errors: If BlobPath is invalid, an error will display.
Example
The following example reads the contents of a text file from CYGDEMO.BSS on domain 10003.
Sub readString()
Dim objFileSystem
Set objFileSystem = CreateObject("CxScript.FileSystemObject")
Dim strRet
strRet = objFileSystem.ReadBlobString("[10003]CYGDEMO.BSS\INCLUDE\READTEST.TXT")
WScript.Echo strRet
End Sub
UndoCheckOut
The UndoCheckOut method revokes a check out for a Blob file. Optionally allows a user with admin access to force an undo action against another user's checkout.
Syntax
UndoCheckOut(BlobPath As String, ForceUndo As Boolean) As Boolean
Parameters
| Parameter | Required | Description |
|---|---|---|
|
BlobPath |
Yes |
A valid Blob file path, in "site.service\folder\file" format. |
|
ForceUndo |
Yes |
A Boolean value indicating whether or not to force an undo action against another user's checkout. |
UploadFileToBlob
The UploadFileToBlob method uploads the specified file from a local source directory to the specified Blob folder.
Syntax
UploadFileToBlob(BlobSiteService As String, BlobFolder As String, SourceFileName As String, SourceFileDirectory As String, UpdateRulesMask As Integer) As Boolean
Parameters
| Parameter | Required | Description |
|---|---|---|
|
BlobSiteService |
Yes |
A valid service name, in "site.service" format. |
|
BlobFolder |
Yes |
A valid foldername in BlobSiteService. |
|
SourceFileName |
Yes |
The file name of the file to copy. |
|
SourceFileDirectory |
Yes |
The directory of the file to copy. |
|
UpdateRulesMask |
Yes |
Used to determine whether the file will be uploaded or downloaded. Set to 1 to update the rules mask, or 0 to leave it as is. See UpdateRulesMask for more information about this parameter. |
Remarks
Return Value: A Boolean indicating if the method succeeded.
Errors: If any of the properties are invalid, an error will display.
Example
The following example uploads C:\MyFolder\TestScreen.csf to CYGDEMO.BSS\TEST and tells the user whether or not the operation was successful.
Sub uploadFile()
Dim objFileSystem
Set objFileSystem = CreateObject("CxScript.FileSystemObject")
Dim bRet
bRet = objFileSystem.UploadFileToBlob("CYGDEMO.BSS", "TEST", _
"TestScreen.csf", "C:\MyFolder", 0)
If bRet Then
edtMessageBox.Text = "File upload successful"
Else
edtMessageBox.Text = "Error uploading file"
End If
End Sub
UploadFileToBlobPath
The UploadFileToBlobPath method uploads the specified file from a local source directory to the specified Blob path.
Syntax
UploadFileToBlobPath(BlobPath As String, SourceFileName As String, SourceFileDirectory As String, UpdateRulesMask As Integer) As Boolean
Parameters
| Parameter | Required | Description |
|---|---|---|
|
BlobPath |
Yes |
A valid Blob file path, in "site.service\folder\file" format. |
|
SourceFileName |
Yes |
The file name of the file to copy. |
|
SourceFileDirectory |
Yes |
The file directory of the file to copy. |
|
UpdateRulesMask |
Yes |
Used to determine whether the file will be uploaded or downloaded. Set to 1 to update the rules mask, or 0 to leave it as is. See UpdateRulesMask for more information about this parameter. |
Remarks
Return Value: A Boolean indicating if the method succeeded.
Errors: If any of the properties are invalid, an error will display.
Example
The following example uploads C:\MyFolder\uploadtest.txt to CYGDEMO.BSS\TEST\uploadtest.txt and tells the user whether or not the operation was successful.
Sub uploadFilePath()
Dim objFileSystem
Set objFileSystem = CreateObject("CxScript.FileSystemObject")
Dim bRet
bRet = objFileSystem.UploadFileToBlobPath("CYGDEMO.BSS\TEST\file.txt", _
"uploadtest.txt", "C:\MyFolder", 0)
If bRet Then
edtMessageBox.Text = "File upload successful"
Else
edtMessageBox.Text = "Error uploading file"
End If
End Sub
WriteBlobString
The WriteBlobString method writes the provided string to the specified Blob path.
Syntax
WriteBlobString(BlobPath As String, Value As String) As Boolean
Parameters
| Parameter | Required | Description |
|---|---|---|
|
BlobPath |
Yes |
A valid Blob file path, in "site.service\folder\file" format. |
|
Value |
Yes |
The information to store in the file. |
Remarks
If any folders in BlobPath do not exist, they will be created.
Return Value: A Boolean indicating if the method succeeded.
Example
The following example writes information to CYGDEMO.BSS\WRITE\Stuff.txt and tells the user whether or not the operation was successful.
Sub writeBlob()
Dim objFileSystem
Set objFileSystem = CreateObject("CxScript.FileSystemObject")
Dim bRet
bRet = objFileSystem.WriteBlobString("CYGDEMO.BSS\Write\Stuff.txt", "text text")
If bRet Then
edtMessageBox.Text = "File upload successful"
Else
edtMessageBox.Text = "Error uploading file"
End If
End Sub


