#727 – Getting a List of Files from the Clipboard

In Windows, if you do a Copy operation on a set of files, a list of filenames will get added to the clipboard.  You can get access to this list of files using the Clipboard.GetFileDropList method.

    public partial class MainWindow : Window, INotifyPropertyChanged
        public MainWindow()
            this.DataContext = this;

        public StringCollection FileList { get; set; }

        private void btnPasteFileList_Click(object sender, RoutedEventArgs e)
            if (Clipboard.ContainsFileDropList())
                FileList = Clipboard.GetFileDropList();

        public event PropertyChangedEventHandler PropertyChanged;

        private void RaisePropertyChanged(string prop)
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(prop));

The XAML for this sample includes a ListBox that just binds to the FileList property.


        <ListBox ItemsSource="{Binding FileList}"/>
        <Button Grid.Column="1" Content="Paste File List"
                VerticalAlignment="Top" HorizontalAlignment="Left"
                Padding="10,5" Margin="10"



About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

One Response to #727 – Getting a List of Files from the Clipboard

  1. Pingback: Dew Drop – December 4, 2012 (#1,475) | Alvin Ashcraft's Morning Dew

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: