Exemplo n.º 1
0
    /// <summary>
    /// Handles actions occurring when some item is deleted.
    /// </summary>
    /// <param name="argument">Argument holding information on deleted item</param>
    private void HandleDeleteAction(string argument)
    {
        if (!string.IsNullOrEmpty(argument))
        {
            string[] argArr = argument.Split(ARG_SEPARATOR);
            if (argArr.Length >= 2)
            {
                // Get information from argument
                string path   = argArr[0];
                bool   isFile = ValidationHelper.GetBoolean(argArr[2], true);

                if (path.StartsWithCSafe(NodeID, true))
                {
                    if (isFile && File.Exists(path))
                    {
                        File.Delete(path);
                    }
                    else if (Directory.Exists(path))
                    {
                        Directory.Delete(path);
                    }
                }
                else
                {
                    ShowError(GetString("dialogs.filesystem.invalidfilepath"));
                }

                // Load new data filtered by searched text
                fileSystemView.SearchText   = LastSearchedValue;
                fileSystemView.StartingPath = NodeID;

                // Reload the file system view
                fileSystemView.Reload();
                pnlUpdateView.Update();

                // Clear selected item
                ItemProperties.ClearProperties();
                pnlUpdateProperties.Update();
            }
        }

        // Forget recent action
        ClearActionElems();
    }