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
Asked
Active
Viewed 1,093 times
0
-
Did you search these forums? http://stackoverflow.com/questions/3546016/how-to-copy-data-to-clipboard-in-c-sharp – poco Jul 20 '12 at 03:53
-
updated question..plus i need the name of the file – Hunter Mitchell Jul 20 '12 at 03:55
2 Answers
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
-
get the file name from the code I posted in chat , this is for if there is an image in clipboard – Scott Selby Jul 20 '12 at 04:06