Description
The slPacker.GetFileListFromFolder
method returns a list of names for folders and files that exist in a particular folder. You can pass this list to the slPacker.Pack
method as the first parameter in order to compress the listed files along with the files belonging to the listed folders.
Declaration
Applies To
The method is applied to the following object:
Parameters
The method has the following parameter:
FolderName
The path to the desired folder.
Result Value
A string that represents a list of files’ and folders’ names. Individual file and folder names are separated in the list by the (0Dh
, 0Ah
) characters.
Remarks
The list returned by GetFileListFromFolder
does not include names of files and subfolders belonging to the given folder's top-level subfolders.
Example
The following example demonstrates how to obtain the list of files and folders that belong to the specified folder and how to use the list to compress the files.
JavaScript, JScript
function PackFiles()
{
var WorkDir, FileList, ArchivePath;
// Specifies the path to the folder that contains the files to compress
WorkDir = "D:\\Work Folder\\ExportedLog\\Files";
// Obtains the list of files residing in the specified folder
FileList = slPacker.GetFileListFromFolder(WorkDir);
// Checks that the file list is not empty
if (FileList != "")
{
ArchivePath = WorkDir + "\\ArchivedFiles";
// Compresses the files and checks whether they have been compressed successfully
if (slPacker.Pack(FileList, WorkDir, ArchivePath))
Log.Message("The files have been compressed successfully");
}
}
Python
def PackFiles():
# Specifies the path to the folder that contains the files to compress
WorkDir = "D:\\Work Folder\\ExportedLog\\Files"
# Obtains the list of files residing in the specified folder
FileList = slPacker.GetFileListFromFolder(WorkDir)
# Checks that the file list is not empty
if (FileList != ""):
ArchivePath = WorkDir + "\\ArchivedFiles"
# Compresses the files and checks whether they have been compressed successfully
if (slPacker.Pack(FileList, WorkDir, ArchivePath)):
Log.Message("The files have been compressed successfully")
VBScript
Sub PackFiles
Dim WorkDir, FileList, ArchivePath
' Specifies the path to the folder that contains the files to compress
WorkDir = "D:\Work Folder\ExportedLog\Files"
' Obtains the list of files residing in the specified folder
FileList = slPacker.GetFileListFromFolder(WorkDir)
' Checks that the file list is not empty
If FileList <> "" Then
ArchivePath = WorkDir + "\ArchivedFiles"
' Compresses the files and checks whether they have been compressed successfully
If slPacker.Pack(FileList, WorkDir, ArchivePath) Then
Log.Message("The files have been compressed successfully")
End If
End If
End Sub
DelphiScript
procedure PackFiles();
var WorkDir, FileList, ArchivePath;
begin
// Specifies the path to the folder that contains the files to compress
WorkDir := 'D:\Work Folder\ExportedLog\Files';
// Obtains the list of files residing in the specified folder
FileList := slPacker.GetFileListFromFolder(WorkDir);
// Checks that the file list is not empty
if FileList <> '' then
begin
ArchivePath := WorkDir + '\ArchivedFiles';
// Compresses the files and checks whether they have been compressed successfully
if slPacker.Pack(FileList, WorkDir, ArchivePath) then
Log.Message('The files have been compressed successfully');
end;
end;
C++Script, C#Script
function PackFiles()
{
var WorkDir, FileList, ArchivePath;
// Specifies the path to the folder that contains the files to compress
WorkDir = "D:\\Work Folder\\ExportedLog\\Files";
// Obtains the list of files residing in the specified folder
FileList = slPacker["GetFileListFromFolder"](WorkDir);
// Checks that the file list is not empty
if (FileList != "")
{
ArchivePath = WorkDir + "\\ArchivedFiles";
// Compresses the files and checks whether they have been compressed successfully
if (slPacker["Pack"](FileList, WorkDir, ArchivePath))
Log["Message"]("The files have been compressed successfully");
}
}