C# 数据复制到粘贴板

using SoftRGB.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Yang.Common.Helper
{
    public static class ClipboardHelper
    {
        /// <summary>
        /// 数据复制到系统粘贴板
        /// add  by yangxp@20180528 
        /// </summary>
        /// <param name="data">待复制数据</param>
        /// <param name="times">尝试次数</param>
        /// <returns>是否成功</returns>
        public static bool  CopyData(string data, int times)
        {
            try
            {
                bool result = false;
                if (string.IsNullOrEmpty(data))
                    return false;
                else
                {
                    System.Windows.Forms.Clipboard.SetDataObject(data.ToString(), true, 3, 100);
                    result = true;
                }
                return result;
            }
            catch (Exception ex)
            {
                RGBMessageBox.Show("复制失败:剪贴板被其他线程或应用程序占用。
" + ex.Message, mesBoxType: RGBMesType.Error);
                return false;
            }
 
        }
    }
}

转 :  https://blog.csdn.net/qq_23018459/article/details/80483132

原文地址:https://www.cnblogs.com/fps2tao/p/15011277.html