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 on a Remote Desktop Computer, it doesn't work. The question is: why?
Copy/paste works remotely 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:
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.
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 out. 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 remotely copied file:
Do you have any idea?
Many thanks in advance.
User contributions licensed under CC BY-SA 3.0