コード例 #1
0
ファイル: Program.cs プロジェクト: stebanmd/paste_to_file
        private static void Main(string[] args)
        {
            string fileName = ContextUtil.GetFileName();
            string diretory = string.Join(" ", args);

            if (string.IsNullOrWhiteSpace(diretory) || string.IsNullOrWhiteSpace(fileName))
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainForm(fileName));
            }
            else
            {
                try
                {
                    PasteUtil.PasteToFile(diretory);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
コード例 #2
0
 public static void PasteToFile(string path)
 {
     if (Clipboard.ContainsImage() || Clipboard.ContainsText() || Clipboard.ContainsFileDropList())
     {
         string baseTargetName = path + "\\" + ContextUtil.GetFileName();
         if (Clipboard.ContainsText())
         {
             CreateTextFile(baseTargetName);
         }
         else if (Clipboard.ContainsImage())
         {
             CreateImageFile(baseTargetName);
         }
         else
         {
             CopyFilesToDirectory(baseTargetName);
         }
     }
     else
     {
         throw new Exception("Não há dados reconhecíveis na área de transferência.");
     }
 }