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

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?

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.

Related

Save any file type copied into the Clipboard

I'm working with the code from this Stack article (specifically the second answer) to monitor when the clipboard changes. The end goal for this application is that the user can copy any file type (whether it's a .xlsx, .pk3, .sln, etc), folder, an image or a string and have it automatically saved to their temp directory. I would set file size limits though so that the temp folder doesn't get overloaded. The overall concept of the application is to provide convenience, so users can recover data that was copied but then deleted or lost.
So far, the above referenced code is working great for strings and images. However, after reviewing the items in the DataFormats list (i.e. usage: DataFormats.Bitmap), I can't find a catch-all for any file type, or for folders. I also can't find any way to determine what type of file was copied. Is there any way to determine that? For example, if there was a way to get the file extension of the file copied, that would help.
Maybe my hopes are set too high. Even if I kept an array of allowed file types (.xlsx, .sln, etc) there would be no way I can think of to save that type of file. It seems I can't get bytes from a DataObject type, which would be the easy way out.
Any ideas on how I could accomplish this? Thanks.
The reason, why you can't find a catch all, is because every format is registered on the host machine, by the applications using that file format.
you can get the current list of fileformats that the object held in the clipboard has by using
string[] formats = iData.GetFormats();
But couldn't you just serialize (to exact copy) what ever data comes in and save it as the last entry in Clipboard.GetFileDropList();
seems like all files that arent audio/images/string has a very specific set of formats
well anyway, just my thoughts
maybe look here
http://www.codeproject.com/Articles/15333/Clipboard-backup-in-C

How to get copied text from memory without pasting?

I got one requirement which is when the user copy any text the system should get the copied text from the memory into the program without require the user to paste it in a txtbox or similar control. I searched on the internet but I didn't get any information. can somebody suggest or provide some references so that I can follow...????
any help would be highly appreciated...!!!!
From a web development standpoint, you can not access the clipboard directly. You will have to create either a Flash or Silverlight hook into the clipboard to get the data.
Example
Another Example
For security reasons, you will never be able to do that in Javascript.
As it is already pointed out accessing clipboard is either not possible or restricted for security reasons for all components running on a page in a browser (restricted == is unlikely to be enabled by anyone, especially for such "spy on clipboard" purpose).
For standalone application you can either scan clipboard all the time or use clipboard filters.
Native functions are around SetClipboardViewer and GetClipboardData.
Managed: Clipboard.

C# Drag and Drop functionality

I'm trying to achieve functionality similar to winzip/winrar, etc. I have a Treeview that displays the contents of a package (System.IO.Packaging). I want to be able to drag and drop a file or folder from the TreeView onto an explorer window or the desktop, etc. My problem is that I have to call DoDragDrop before I know if the object was actually even dropped. That means to create the DataObject with the FileDrop type, I must extract those contents of the package out to a temporary area and then provide that path to the DataObject before calling DoDragDrop. If the user doesn't drop on a capable container or cancels the drop, the overhead of extracting those contents is wasted. I've noticed that winzip does not actually create the temporary file until the drop occurs on a valid target. I've checked the DataFormats provided by the WinZip drop and they are normal FileDrop, FileNameW, FileName and Shell IDList Array. The first three simply hold a string to the temporary location that winzip extracted that file to. I'm not sure what the last one does.
Long story short, I want to be able to avoid extracting the contents until I know the drop location was valid. Is there a callback to figure out the drop location? Any suggestions would be extremely helpful.
System.Windows.DragDropEffects de = DragDrop.DoDragDrop(treeview1, dataObj, System.Windows.DragDropEffects.Move);
I've tried this with an application similar to an FTP server - I wanted to start downloading only after the user actually dropped the item. Unfortunately I found no way to do this using managed code only.
The way WinZip probably does it is by receiving COM callbacks (please forgive me if I'm using the wrong words here) and you'd have to create a managed wrapper around the native COM object in order to receive such callbacks yourself.
It's certainly possible, but I gave up and embedded a FolderTreeView thingie in my application to catch the drop events myself :/

Drag and Drop a Groupwise Email to C# Winform

I have a need to be able to drag and drop a groupwise email to my winform application and am not having any luck at all.
I am able to get a filename as such but it is only a name, not a path.
Every time I call
e.Data.GetData("FileContents", true))
or
e.Data.GetData("FileContents", false))
or
e.Data.GetData("FileContents"))
I get null returned.
Also, the GetFormats returns something strange and a simple Google search returned nothing. One of the formats was WPOF_DBOBJ_DRN.
If anyone has some insight on this it would be greatly appreciated.
Update:
Just to add a few more details about this, there is also nothing on the clipboard from the drag and drop. Also took a look at the groupwise editor and word perfect isn't even installed on my pc and is most definatly not the editor.
Have a look at the following links (I know, some of them are for Delphi, but you should get the idea):
Drag and drop from an email file attachment in GroupWise to a .NET application
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_21198933.html
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_23015275.html
I'll take a look at trying that. I've also tried to implement the IStorage interface into an IDataObject interface using unmanaged code and still aren't having any luck. (The Interface is also used to get Outlook messages that are dragged and dropped and works fine.)
That format is most definatly one of the formats i get back from calling e.Data.GetFormats();
I'll take a look at that link. Thanks
WPOF_DBOBJ_DRN looks like WordPerfect Office Format - Database Object. I can't figure out what the DRN stands for though. See if you can open the unreadable file with Word, or WordPerfect if you have it. My guess is that the setup of GroupWise that you are using has WordPerfect as its editor.

Drag Drop to the Desktop after creation of the file? (C#)

I have a query about drag-drop in C# using .NET.
My issue is with remote files. I have a list of remote files which the user can drag into an explorer window (desktop, etc). When such a drag occurs I want to be able to download the file and write it to the drop location.
The normal method of dragging files:
private void StartDragDrop(string FileToDrag)
{
MyControl.DoDragDrop(new DataObject(DataFormats.FileDrop, FileToDrag), DragDropEffects.Copy);
}
...does not suit my needs as I will not have the file data to populate the drag-drop object until after the DROP.
I have seen this functionality in many FTP clients and such.
Thanks in advance wizards.
It appears there is no logically straight forward method to do such a thing.
But there is a work around (with a substantial amount of work for such basic functionaliy) that can be found at codeproject.
If anyone finds a tidy way of doing it, let me know, I'd be intrigued.

Categories

Resources