Hack Forums
[C#] Simple "drag-drop or click" file browse control - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] Simple "drag-drop or click" file browse control (/showthread.php?tid=5825282)



Simple "drag-drop or click" file browse control - gigajew - Apr 15, 2018

Easy to use, plug-and-play "drag-drop or click" file browse control. You can access the selected file by the property "SelectedFile", which is of the type "FileInfo".

[Image: aN3ivZe.png]



RE: Simple "drag-drop or click" file browse control - th3s3cr3t0n3 - Apr 16, 2018

Nice release man, thanks for sharing. I'm sure someone has a use for this. Almost like I want to grab and keep for most future programs with an upload feature :).

IMAGINARY +1 REP


RE: Simple "drag-drop or click" file browse control - 0xDEAD10CC - Apr 16, 2018

Won't work on more elevated programs Vista+. (https://blogs.msdn.microsoft.com/patricka/2010/01/28/q-why-doesnt-drag-and-drop-work-when-my-application-is-running-elevated-a-mandatory-integrity-control-and-uipi/)

https://helgeklein.com/blog/2010/03/how-to-enable-drag-and-drop-for-an-elevated-mfc-application-on-vistawindows-7/


RE: Simple "drag-drop or click" file browse control - severos - Apr 18, 2018

I haven't read the full source, but would you mind me asking about those lines:
PHP Code

<?php 
string
[] droppedFiles = (string[])e.Data.GetData(DataFormats.FileDrop);
            foreach (
string fileName in droppedFiles)
            {
                
SelectedFile = new FileInfo(fileName);
                break;
            } 
Why not use casting with 'as' then check for null instead of throwing exceptions?
and why using a 'foreach' when you're breaking after the very first element??