I haven't actually done it because it's not in my project scope, but it
shouldn't be too hard from what I've seen. You basically just do the
reverse. This is completely untested code, and will just get you started,
but it should go a little something like this:
IDataObject objData2 = Clipboard.GetDataObject();
if(objData2.GetDataPresent(DataFormats.FileDrop, true)) // Check to see if
the data is in the clipboard
{
//Create file using something like:
//myFile = objData2.GetData(DataFormats.FileDrop, true);
//and then write it out using the System.IO namespace classes
}
When you figure it out, post it here for the future frustrated programmer to
see
"Dhans" <(E-Mail Removed)> wrote in message
news:8D447D1E-9B31-43BC-98A0-(E-Mail Removed)...
> Smith,
> Similar problem i am facing, thanks for your code snippet for file
> copying to clipboard.
> Now, how do I get back that file from clipboard or paste in some other
> location.
>
> Thanks,
> Dhans
>
> "John Smith" wrote:
>
> > Finally got it and it's pretty easy. I was trying this earlier and it
> > wasn't working, but that's because I didn't have the file name as an
array
> > (how annoying!):
> >
> > DataObject objData = new DataObject();
> > string []filename = new string[1];
> > filename[0] = "c:\\testFile.exe";
> > objData.SetData(DataFormats.FileDrop, true, filename);
> > Clipboard.SetDataObject(objData, true);
> >
> >
> >
> > "John Smith" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > Sorry....no go. I need a real sample of copying a file to the
clipboard.
> > > Seems like the only file that's easy to copy is a bitmap image.
> > > Anyone got one? It seems like it's never been done before. I've been
> > > researching it for hours.
> > >
> > >
> > > "Oliver Sturm" <(E-Mail Removed)> wrote in message
> > > news:(E-Mail Removed)...
> > > > John Smith wrote:
> > > >
> > > > >Does anyone have any sample code for how to copy the file
C:\test.txt
> > > into
> > > > >the user's clipboard? I need to support multiple filetypes (like
pdf,
> > > doc,
> > > > >zip...).
> > > >
> > > > You don't really copy the file to the clipboard, but rather a
reference
> > to
> > > > it in the form of a PIDL (a Windows Shell id). You also need to
adhere
> > to
> > > > a specific format called "Shell IDList Array". I searched Google for
it
> > > > and found a nice CodeProject article that shows something quite
similar
> > in
> > > > VB.NET. Here it is:
> > > http://www.codeproject.com/useritems...eeDragDrop.asp
> > > >
> > > >
> > > > Oliver Sturm
> > > > --
> > > > Expert programming and consulting services available
> > > > See http://www.sturmnet.org (try /blog as well)
> > >
> > >
> >
> >
> >