0

I have been searching and searching and searching for some code that will allow me to do this but i have gotten nothing. Lets say i copied a file, or image file. It is on my clipboard. How do i get the name of the file or image file i have copied? I already know the text copied or the image, but i need the name of the file. e.g: image.png

Hunter Mitchell
  • 7,063
  • 18
  • 69
  • 116

2 Answers2

1

Are you looking for this method?

Clipboard.GetFileDropList()

Edit:

StringCollection fileNameCollection = Clipboard.GetFileDropList();
            string copiedFilePath = (fileNameCollection != null && fileNameCollection.Count > 0) ? fileNameCollection[0] : null;
danish
  • 5,550
  • 2
  • 25
  • 28
0

try this :

public System.Drawing.Image SwapClipboardImage(
System.Drawing.Image replacementImage)
{
System.Drawing.Image returnImage = null;
if (Clipboard.ContainsImage())
{
    returnImage = Clipboard.GetImage();
    Clipboard.SetImage(replacementImage);
}
return returnImage;
}

from here link

Scott Selby
  • 9,420
  • 12
  • 57
  • 96