Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8925149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:37:15+00:00 2026-06-15T07:37:15+00:00

Thanks to Stack Overflow question Copy files to clipboard in C# , I was

  • 0

Thanks to Stack Overflow question Copy files to clipboard in C#, I was able to use Clipboard.SetFileDropList and end up with:

using System;
using System.Collections.Specialized;
using System.Windows.Forms;

class Program
{
    [STAThread]
    static void Main ( string[] args)
    {    
        StringCollection paths = new StringCollection();
        paths.Add( @"C:\Users\Antonio\Desktop\MyDirectory" );
        Clipboard.SetFileDropList( paths);
    }
}

That way I can place an entire directory on the clipboard and paste it where I need it to. I would like to be able to paste it with code though. I don’t want to go to the place where I want to paste it and then press Ctrl + V. In other words, I am looking for something like:

Clipboard.Paste("C:\Users\LocationWhereIWantToPasteTheFolder")

I know I can get all the files recursively and then paste them one by one. But why reinvent the wheel? It will be nice if the OS can do it for me…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:37:18+00:00Added an answer on June 15, 2026 at 7:37 am

    The Clipboard has a protocol, a mutually agreed-upon way to get data from one process to another. Such a protocol needs to have limited ways to put sensible data on the clipboard. You can put whatever you want on the clipboard, notably a .NET object. But if the other app that pastes the clipboard data doesn’t understand .NET objects, highly likely if it wasn’t written in .NET then it is just going to exclaim WTF.

    So the method you are using is just a little Clipboard class helper method that puts data on the clipboard using a standard protocol. One that another app is likely to understand, but no guarantee. The protocol is DataFormats.FileDrop.

    Your intended replacement will work just fine too, you can certainly put a string on the clipboard. The most basic thing you’d ever want to copy/paste. But the app that pastes it will only recognize it as just a string. It has no clue that the string is supposed to mean something else. The protocol is DataFormats.Text.

    The solution is very simple, just write a little private helper method that takes a string. And uses Directory.GetFiles() to create a StringCollection that you put on the clipboard. Simple, mission accomplished, kiss.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is the code I'm using ( from this Stack Overflow question , although
Thanks to the answer on this stackoverflow question I was able to get the
Thanks to stack overflow I'm almost done with a programming problem that's been driving
Thanks to Stack Overflow and you guys i successfully completed my first project (viz.
Stack Overflow has this question answered in many other languages, but not C. So
I found this piece of code from an earlier Stack Overflow question which describes
I think I have read every article and stack overflow question regarding this, but
I read an answer to a question on Stack Overflow that contained the following
I have a reputation system on my site, similar to Stack Overflow, where a
Sup fellas, I am using the script that a fellow stack overflow user posted

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.