Hi Experts,
A file (from File Explorer) has been copied using <Ctrl><C>. The content of the file must be pasted into a RichTextBox, if the file is a picture (e.g. in JPG format) - similarly to Microsoft Word. It's already implemented and works without any problem - but only locally. If the copied file was locally, but should be pasted on a Remote Desktop Computer, it doesn't work. The question is: why?
Copy/paste works locally/remotely, respectively, without any problem: e.g. a simple text (not a file!) or a picture (opened in Paint) can be copied/pasted (has been checked by Free Clipboard Viewer 4.0).
Some additional information:
Locally copied file, clipboard viewed locally
Clipboard contains data "DataFormats.FileDrop". Clipboard.GetDataObject().GetFormats() gives the following string array:
[0] "Shell IDList Array"
[1] "DataObjectAttributes"
[2] "DataObjectAttributesRequiringElevation"
[3] "Shell Object Offsets"
[4] "Preferred DropEffect"
[5] "AsyncFlag"
[6] "FileDrop"
[7] "FileNameW"
[8] "FileName"
[9] "FileContents"
[10] "FileGroupDescriptorW"
The whole path can be gained using Clipboard.GetFileDropList()[0] (or with FileNameW), and the picture can be imported into my application.
Locally copied file, clipboard viewed remotely
The format of the data is unknown (cannot be found in DataFormats class). Clipboard.GetDataObject().GetFormats() gives the following string array:
[0] "FileGroupDescriptorW"
[1] "FileContents"
[2] "Preferred DropEffect"
[3] "CanIncludeInClipboardHistory"
[4] "CanUploadToCloudClipboard"
Using "FileGroupDescriptorW" the name of the file (without the path) can be gained. Only the filename, without any path information (most probably the locally valid path information wouldn't be sense remotely).
Clipboard.GetData("FileContents") throws an exception: System.Runtime.InteropServices.COMException: 'Data on clipboard is invalid (Exception from HRESULT: 0x800401D3 (CLIPBRD_E_BAD_DATA))'
However the locally copied file:
can be pasted into the remote file system, or
can be pasted on remote PC e.g. into Microsoft Word without any problem. It means, that the content of the copied file can be found on the Clipboard - but not accessible. Most probably the "FileContents" should be suitable to get it.
Do you have any idea?
Many thanks in advance.