Results 1 to 7 of 7

Thread: Copy File To Clipboard {RESOLVED}

  1. #1

    Thread Starter
    Fanatic Member cpatzer's Avatar
    Join Date
    Sep 2004
    Posts
    537

    Question Copy File To Clipboard {RESOLVED}

    Ok,

    I have a string filename:

    c:\temp.jpg

    *Could be any extension .jpg,.tiff,.txt,.php,.html...

    I want to put this file in the clipboard as if I had right clicked on it in windows explorer and selected copy so that the user can later paste it elsewhere on their file system.

    Does anybody have any clue as to how to do this with:

    Clipboard.SetDataObject

    Thanks in advance
    Last edited by cpatzer; Oct 7th, 2004 at 06:40 PM.
    In life you can be sure of only two things... death and taxes. I'll take death.

  2. #2
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036
    Hi

    VB Code:
    1. Dim DataObject As New DataObject
    2.         Dim file As String = "C:\TESTE.PDF"
    3.         DataObject.SetData(DataFormats.FileDrop, True, file)
    4.         Clipboard.SetDataObject(DataObject)

    Regards
    Jorge
    "The dark side clouds everything. Impossible to see the future is."

  3. #3

    Thread Starter
    Fanatic Member cpatzer's Avatar
    Join Date
    Sep 2004
    Posts
    537
    Jorge,

    Did you test this on your machine?
    It looks right, but won't work on my machine.

    When I try to paste it into a folder or my desktop, I get the hour glass for a second but no file is pasted.

    Thanks again
    In life you can be sure of only two things... death and taxes. I'll take death.

  4. #4
    Addicted Member
    Join Date
    Sep 2004
    Location
    Brooklyn
    Posts
    147
    Did you try it with a .jpg or .txt file? I'm guessing you can't do with this with .pdf content ...

  5. #5
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036
    Hi Cpatzer

    Your are correct using the windows explorer paste doesn't do anything but i tried

    Clipboard.GetDataObject with both .pdf and .wav where copied the files on the destination directory.

    Regards
    Jorge
    "The dark side clouds everything. Impossible to see the future is."

  6. #6

    Thread Starter
    Fanatic Member cpatzer's Avatar
    Join Date
    Sep 2004
    Posts
    537
    Well, that is what I need, to be able to have the user then paste it wherever they want.

    Any ideas?
    In life you can be sure of only two things... death and taxes. I'll take death.

  7. #7

    Thread Starter
    Fanatic Member cpatzer's Avatar
    Join Date
    Sep 2004
    Posts
    537
    Solution


    Code:
                Dim DataObject As New DataObject
                Dim tempFileArray(0) As String
                'NOTE THAT IT MUST BE PASSED AN ARRAY!!!
                tempFileArray(0) = activeListView.SelectedItems(0).Tag
                DataObject.SetData(DataFormats.FileDrop, False, tempFileArray)
                Clipboard.SetDataObject(DataObject)




    Thanks to all.
    In life you can be sure of only two things... death and taxes. I'll take death.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width