Hunter Mitchell
Hunter Mitchell

Reputation: 7293

Clipboard Data Source in C#

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

Upvotes: 0

Views: 1115

Answers (2)

danish
danish

Reputation: 5600

Are you looking for this method?

Clipboard.GetFileDropList()

Edit:

StringCollection fileNameCollection = Clipboard.GetFileDropList();
            string copiedFilePath = (fileNameCollection != null && fileNameCollection.Count > 0) ? fileNameCollection[0] : null;

Upvotes: 1

Scott Selby
Scott Selby

Reputation: 9580

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

Upvotes: 0

Related Questions