Search code examples
c#wpfclipboard

Why cant I get Data from ClipBoard trough an Remote Desktop session?


I want to get the Data from the ClipBoard on an RemoteDesktop.

The Data Ive getting is an path of an File I have in ClipBoard

The Code im using looks like this:

   IDataObject data = Clipboard.GetDataObject();

                if (!data.GetDataPresent(DataFormats.FileDrop))
                    return;

                string[] filePath = (string[])
                  data.GetData(DataFormats.FileDrop);

And for the local Computer its working perfectly.

But when Im using the Programm on an Remote Computer I cant use the ClipBoard there.

Clipoard is activated on Remote so If i want to paste something from my ClipBoard normal on the Remote Computer its working but my Code dosent find an ClipBoard.

Someone an Idea?


Solution

  • I don't think DataFormats.FileDrop is the correct format for what you want. According to MSDN:

    Use this format to interact with shell file drags during drag-and-drop operations.

    You don't want drag-and-drop, you're using the clipboard.

    You can call data.GetFormats() to get a list of the available formats the object supported by on the clipboard. When I test this I see two formats that may be useful to you: FileGroupDescriptorW and FileContents. I would suggest looking into those and learning how to parse the data therein.

    One place you might look to get started with FileGroupDescriptorW is here. They're doing something lightly different (trying to get drag and drop from Outlook), but they make use of FileGroupDescriptorW and have all the needed definitions that are currently missing from pInvoke.net.