-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please provide a function that could be used to get/set ShellItems in NativeClipboard #353
Comments
Does |
But ShellDataObject rely on System.Windows.Forms which is not friendly to use if someone who do not use WinForms. |
Got it. Let me see if I can port the |
Thanks, do you have any demo to tell us how to use ShellDataObject with ShellItem (Includes Get/Set ShellItem and Set ShellItem with something custom data which stored in another clipboard id) |
…lable(string) and SetShellItems methods (#353)
I added a couple methods to NativeClipboard. Give them a try and let me know your thoughts. |
Due to NativeClipboard not working in my project, I have not be able to test that but I reviewed the code, it looks great. #355 (comment) |
I'll see if I can troubleshoot #355 over the next few days. |
I found some issues, I could not retrieve the ShellItem which I just set into clipboard IEnumerable<ShellItem> Items = Collection.Select((Item) => new ShellItem(Item.Path));
try
{
NativeClipboard.SetShellItems(Items);
if (NativeClipboard.GetShellItemArray() is ShellItemArray Array)
{
foreach (ShellItem Item in Array)
{
System.Diagnostics.Debug.WriteLine($"Shell IDList: {Item.FileSystemPath}");
}
}
else
{
//Runs to here which means no available Shell IDList Array
System.Diagnostics.Debug.WriteLine("No available Shell IDList Array");
}
}
catch (Exception)
{
}
finally
{
Items.ForEach((Item) => Item.Dispose());
} |
The latest AppVeyor package seems to be working. I used this code behind a button in a WinForms project and consistently got what I expected. string[] fileNames = new[] { @"C:\file1.txt", @"C:\file2.txt" };
NativeClipboard.SetShellItems(fileNames.Select(ShellItem.Open));
MessageBox.Show(string.Join("\n", NativeClipboard.GetShellItemArray().Select(i => i.FileSystemPath))); |
Demo for you. Could set the ShellItem but could not retrieve them back |
I think this is now complete. |
Maybe these can help: https://github.com/dahall/Vanara/blob/master/Windows.Shell/ShellObjects/ShellBrowser.cs ...and least but not least: regards, tajbender |
@tajbender What is your last comment regarding? |
Oups, sorry. That was the wrong topic 🍶 |
Is your feature request related to a problem? Please describe.
No
Describe the additions or enhancements you'd like
It would be great if you could provide a way to let us get/set ShellItem(s) through NativeClipboard class easily.
The function like the example below:
The text was updated successfully, but these errors were encountered: