Manipulate file system using Sitemagic CMS

Creating folders, looping through files, and retriving information about items in the file system is possible using the SMFileSystem class. The code below demonstrates various common file system operations.
$imageDir = SMEnvironment::GetFilesDirectory() . "/images";
$oldDir = SMEnvironment::GetFilesDirectory() . "/images/Old";

// Create Old folder if it does not exist
if (SMFileSystem::FolderExists($oldDir) === false)
    SMFileSystem::CreateFolder($oldDir);

// Move all image files to Old folder
$files = SMFileSystem::GetFiles($imageDir);
foreach ($files as $file)
    SMFileSystem::Move($imageDir . "/" . $file, $oldDir . "/" . $file);

// Create backup of downloads folder
$downloadsDir = SMEnvironment::GetFilesDirectory() . "/downloads";
SMFileSystem::Copy($downloadsDir, $downloadsDir . "_backup", true);

// Send file to client browser
SMFileSystem::DownloadFileToClient($downloadsDir . "/Events.pdf");
These are just a few examples of what can be achieved using the SMFileSystem class.