Skip to content

Commit 8b10eb8

Browse files
committed
Added Drop File Constants
1 parent 463ab0d commit 8b10eb8

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

CSharp Code Samples/CodeSamples/ClipboardUse/ClipboardSample.cs

+19-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ namespace CodeSamples.ClipboardUse
66
{
77
internal class ClipboardSample : SampleExecute
88
{
9+
/// <summary>
10+
/// CFSTR_PREFERREDDROPEFFECT
11+
/// </summary>
12+
public const string FileDropEffect = "Preferred DropEffect";
13+
14+
/// <summary>
15+
/// DROPEFFECT_MOVE
16+
/// </summary>
17+
public const byte DropEffectMove = 0x02;
18+
19+
/// <summary>
20+
/// DROPEFFECT_COPY
21+
/// </summary>
22+
public const byte DropEffectCopy = 0x05;
23+
924
private bool HasFilesInClipboard()
1025
{
1126
return Clipboard.GetDataObject().GetDataPresent(DataFormats.FileDrop);
@@ -24,7 +39,7 @@ private void CopyFilesToClipboard(List<string> filesToCopy, bool cutOperation)
2439
//data.SetData("FileDrop", true, files);
2540

2641
MemoryStream memory = new MemoryStream(4);
27-
byte[] bytes = new byte[] { (byte)(cutOperation ? 0x02 : 0x05), 0x00, 0x00, 0x00 };
42+
byte[] bytes = new byte[] { (byte)(cutOperation ? DropEffectMove : DropEffectCopy), 0x00, 0x00, 0x00 };
2843
memory.Write(bytes, 0, bytes.Length);
2944

3045
data.SetData("Preferred DropEffect", memory);
@@ -41,13 +56,13 @@ private List<string> PasteFilesFromClipboard()
4156
IDataObject data = Clipboard.GetDataObject();
4257

4358
string[] files = (string[])data.GetData(DataFormats.FileDrop);
44-
MemoryStream stream = (MemoryStream)data.GetData("Preferred DropEffect", true);
59+
MemoryStream stream = (MemoryStream)data.GetData(FileDropEffect, true);
4560

4661
int flag = stream.ReadByte();
47-
if (flag != 0x02 && flag != 0x05)
62+
if (flag != DropEffectMove && flag != DropEffectCopy)
4863
return result;
4964

50-
bool moveFiles = (flag == 0x02);
65+
bool moveFiles = (flag == DropEffectMove);
5166

5267
foreach (string file in files)
5368
{

0 commit comments

Comments
 (0)