Created
January 13, 2017 21:33
-
-
Save sachintha81/e49bbc1d7dd0e68816225eaa23cb06eb to your computer and use it in GitHub Desktop.
C# - Drag Drop a File/Folder into a TextBox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Windows; | |
using System.Collections.ObjectModel; | |
namespace TextBoxDragDrop | |
{ | |
public partial class TextBoxDragDrop : Window | |
{ | |
private void txtPath_PreviewDragOver(object sender, DragEventArgs e) | |
{ | |
e.Handled = true; | |
} | |
private void txtPath_Drop(object sender, DragEventArgs e) | |
{ | |
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); | |
if (files != null && files.Length != 0) | |
txtPath.Text = files[0]; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment