String.AbbreviateFilePath

string String.AbbreviateFilePath ( 

string FilePath,

number Characters )

Example 1

internal_path = "c:\\windows\\system32\\drivers\\ta_da\\foldername\\driver.vxd";
display_path = String.AbbreviateFilePath(internal_path, 30);

Converts the lengthy internally used path into a more managable size to display to the user (c:\windows\...\driver.vxd)

Example 2

-- callback function for File.Delete action
function DeleteCallBack(source, deleted, total)
    -- set the message and status text
    StatusDlg.SetMessage("Delete: " .. String.AbbreviateFilePath(source, 10));
    StatusDlg.SetStatusText("File " .. deleted .. " of " .. total .. ".");

    -- show the cancel button
    StatusDlg.ShowCancelButton(true, "Cancel");

    -- check if the cancel button was pressed
    bCancel = StatusDlg.IsCancelled();

    -- if the cancel button was pressed, return false, else return true.
    if bCancel then
        return false;
    else
        return true;
    end
end



-- show the status dialog
StatusDlg.Show();

-- delete all files in folder c:\temp, using the DeleteCallBack function
File.Delete("c:\\temp\\*.*", true, true, true, DeleteCallBack);

-- Hide the status dialog
StatusDlg.Hide();

Deletes all files and folders from c:\temp, and uses a callback function to display status to the user.

See also:  Related Actions