Click here to Skip to main content
15,747,139 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have been researching a way to override the file drop behavior into a richtext control in my Windows forms application.

For some file types (Excel, Word, PDF, etc) a object link appears with an icon which is the desired affect. What I don't desire is the attachment (or file) being renamed to its object type (ie. spreadsheet.xlsx is being added as "Microsoft Excel Worksheet" for example). I have verified the "FileDrop", "Filename" and "FilenameW" datatypes do in fact carry the name of the file being drop into the RichText control. I have even tried manually adding them.

Any insight into addressing this problem (if possible) would be appreciated.


PS. CSV, TXT file types seem to work fine.

What I have tried:

Dim ofd As OpenFileDialog = New OpenFileDialog
ofd.Multiselect = True
ofd.Filter = "All Files (*.*)|"

If ofd.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK Then

   Dim fileNames As Specialized.StringCollection = New Specialized.StringCollection()

End If

Asgard25 2-Apr-17 13:18pm    
Have you tried ofd.SafeFileName ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900