using System;
using System.IO;
using System.Windows.Forms;
namespace Clipboard
{
public class Test
{
[STAThread]
public static void Main()
{
System.Windows.Forms.IDataObject o = System.Windows.Forms.Clipboard.GetDataObject();
System.Console.WriteLine(o == null);
foreach(string s in o.GetFormats()){
FileStream fs = new FileStream(Path.Combine("D:\\hogefuga",s.Replace('/','_')),System.IO.FileMode.CreateNew);
Object obj = o.GetData(s);
string s1 = obj as string;
if(s1 != null){
System.IO.StreamWriter sw = new StreamWriter(fs,System.Text.Encoding.UTF8);
sw.WriteLine(s1);
sw.Flush();
sw.Close();
continue;
}
MemoryStream ms = obj as MemoryStream;
if(ms != null){
ms.CopyTo(fs);
fs.Flush();
fs.Close();
continue;
}
byte[] barray = obj as byte[];
if(barray != null){
fs.Write(barray,0,barray.Length);
fs.Flush();
fs.Close();
continue;
}
System.Console.WriteLine(s);
}
System.Console.WriteLine("fin");
System.Windows.Forms.Clipboard.Clear();
}
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uSU87CnVzaW5nIFN5c3RlbS5XaW5kb3dzLkZvcm1zOwoKbmFtZXNwYWNlIENsaXBib2FyZAp7CglwdWJsaWMgY2xhc3MgVGVzdAoJewoJCVtTVEFUaHJlYWRdCgkJcHVibGljIHN0YXRpYyB2b2lkIE1haW4oKQoJCXsKCQkJU3lzdGVtLldpbmRvd3MuRm9ybXMuSURhdGFPYmplY3QgbyA9IFN5c3RlbS5XaW5kb3dzLkZvcm1zLkNsaXBib2FyZC5HZXREYXRhT2JqZWN0KCk7CgkJCVN5c3RlbS5Db25zb2xlLldyaXRlTGluZShvID09IG51bGwpOwoJCQlmb3JlYWNoKHN0cmluZyBzIGluIG8uR2V0Rm9ybWF0cygpKXsKCQkJCUZpbGVTdHJlYW0gZnMgPSBuZXcgRmlsZVN0cmVhbShQYXRoLkNvbWJpbmUoIkQ6XFxob2dlZnVnYSIscy5SZXBsYWNlKCcvJywnXycpKSxTeXN0ZW0uSU8uRmlsZU1vZGUuQ3JlYXRl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