Karan Bains
Karan Bains

Reputation: 99

How to get file path of copied file in Windows?

This is for files which I copy anywhere in explorer either from right click context menu or Ctrl+C.

I looked at System.Windows.Clipboard but there doesn't seem to be a method to get any information about a file which was copied.

Any help in appreciated.

Upvotes: 5

Views: 1278

Answers (2)

David Johnson
David Johnson

Reputation: 9

Please Use This

Clipboard.GetFileDropList();

Upvotes: 0

Nima Talebi
Nima Talebi

Reputation: 874

this work for you

Clipboard is inside System.Windows.Forms, use this way:

if (Clipboard.ContainsFileDropList())
{
    var filesArray = Clipboard.GetFileDropList();
    //now you have a array of file address 
}
else if(Clipboard.ContainsText())
{
    var fileName = Clipboard.GetText();
}

Upvotes: 2

Related Questions