Processing Ajax...

Title
Close Dialog

Message

Confirm
Close Dialog

Confirm
Close Dialog

Confirm
Close Dialog

Get Filenames from Clipboard

Description
If you have file objects on the clipboard (i.e. copied from File Explorer), this macro will get their filenames and put them on the clipboard as a text list.
Language
C#.net
Minimum Version
Created By
Thomas Malloch (BFS)
Contributors
mavaddat, UWK-87
Date Created
Oct 16, 2017
Date Last Modified
Nov 21, 2017

Macro Code

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.IO;

// The 'text' parameter will contain the text from the:
//   - Current Clipboard when run by HotKey
//   - History Item when run from the History Menu
// The returned string will be:
//   - Placed directly on the Clipboard
//   - Ignored by ClipboardFusion if it is 'null'
public static class ClipboardFusionHelper
{
	public static string ProcessText(string text)
	{
        //copy the select item
        BFS.Clipboard.Copy();
	
        //if the clipboard contains a file, return its filename
        if((Clipboard.ContainsFileDropList()) && (Clipboard.GetFileDropList().Count > 0))        
        {
            //Check if multiple files are selected i.e. more than one)
			if(Clipboard.GetFileDropList().Count > 1)
            {
                string FileNames = null;
                
                //Copy all the file names in the selection to FileNames
				for(int fileCount = 0; fileCount < Clipboard.GetFileDropList().Count; fileCount++)
                {
                    FileNames += Path.GetFileName(Clipboard.GetFileDropList()[fileCount]) + Environment.NewLine ;
                }
				return FileNames;
			}
			
            return Path.GetFileName(Clipboard.GetFileDropList()[0]);
        }
 		return text;
	}
}