System.ArgumentException when trying to get items from IStorageFolder (from clipboard)
See original GitHub issueWhen trying to get items from folder, that is retrieved from Clipboard content System.ArgumentException: Value does not fall within the expected range.
exception is thrown.
Here is sample code to reproduce issue:
var cb = Clipboard.GetContent();
var storageItems = await cb.GetStorageItemsAsync();
foreach (var item in storageItems)
{
if (item is IStorageFolder)
{
var pastedFolderItems = await (item as IStorageFolder).GetItemsAsync() // <= Exception
}
else if (item is IStorageFile)
{
// With storage item everyting works.
}
}
Exception Details
System.ArgumentException occurred HResult=0x80070057 Message=Value does not fall within the expected range. Source=System.Private.CoreLib
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
OpenClipboard failed when copy pasting data from WPF ...
Occasionally I get the CLIPBRD_E_CANT_OPEN on some user's systems, ... data from the clipboard as HTML clip = false; while(!clip) { try {...
Read more >Get help with clipboard - Microsoft Support
Learn how to troubleshoot and use the clipboard in Windows to paste multiple items, pin items, and sync your clipboard to the cloud....
Read more >How To Use The Clipboard On Windows 10 | HP® Tech Takes
If you want to delete things one by one, press the Windows key + V keyboard shortcut and go down the list of...
Read more >How to use the Windows clipboard - YouTube
With the Windows 10 clipboard, you can copy multiple images and text at one time. The clipboard previously held one item, but now...
Read more >Have You Tried: Accessing Data from the Clipboard - Blogs
In addition, the clipboard can be used to copy objects and geometry between drawings and layouts, or outside of AutoCAD to other products....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I just confirmed with the feature team that this is a bug and it is being tracked on the product side. It occurs if the folder was placed on the clipboard by a non-UWP app.
This turns out to be on purpose, for security reasons. Otherwise, UWP apps could “steal” any file copied to the clipboard. The code in this repo handles the issue correctly: By catching the exception and reporting that clipboard contents are not available.