0

Previously I was using this code to add only Images to the application (GIFs doesn't work):

 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles BtnImgBrowse.Click
        Dim t As New OpenFileDialog
        t.Filter = "*.JPG;*.PNG;*.GIF|*.JPG;*.PNG;*.GIF"
        If t.ShowDialog = DialogResult.OK Then
            TxtImgFile.Text = t.FileName
            Clipboard.SetImage(Image.FromFile(TxtImgFile.Text))
        End If
    End Sub

Now I want to add PDfs, Documents and Excel file also, So I changed my code little bit, but it doesn't seem to work:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles BtnImgBrowse.Click
    Dim t As New OpenFileDialog
    t.Filter = "*.JPG;*.PNG;*.GIF;*.DOC;*.DOCX;*.XLS;*.XLSX;*.PDF|*.JPG;*.PNG;*.GIF;*.DOC;*.DOCX;*.XLS;*.XLSX;*.PDF"
    If t.ShowDialog = DialogResult.OK Then
        TxtImgFile.Text = t.FileName
        Clipboard.ContainsData(TxtImgFile.Text)
    End If
End Sub

It just copies the Data from my system. Not the file that I select within the application.

Lennart
  • 9,657
  • 16
  • 68
  • 84
  • Possible duplicate of [Copy files to clipboard in C#](https://stackoverflow.com/questions/211611/copy-files-to-clipboard-in-c-sharp) – Visual Vincent Oct 25 '18 at 18:51
  • @K.Dᴀᴠɪs That's Visual Basic (vb) I didn't find any tag named visual basic. Sorry. – Naman Khare Oct 25 '18 at 19:14
  • @K.Dᴀᴠɪs : I know, but the solution is nearly identical in VB.NET. The only thing that really differs are the semicolons at the end of every line and the syntax used when creating the `StringCollection` variable (which can either be easily found via a Google search or converted using an online C# to VB.NET converter). – Visual Vincent Oct 25 '18 at 19:54

0 Answers0