question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

System.ArgumentException when trying to get items from IStorageFolder (from clipboard)

See original GitHub issue

When 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:closed
  • Created 6 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
oldnewthingcommented, Oct 6, 2017

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.

0reactions
oldnewthingcommented, Sep 10, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found