Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
C# - Drag Drop a File/Folder into a TextBox
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
You can’t perform that action at this time.