Click here to Skip to main content
15,889,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm getting an exception when selecting torrent files from a list box

The given key was not present in the dictionary.



C#
public IList<TorrentManager> GetSelectedTorrents()
       {
           IList<TorrentManager> result = new List<TorrentManager>();

               foreach (ListViewItem item in mainForm.TorrentsView.SelectedItems)
                   result.Add(itemToTorrent[item]);


           return result;
       }
Posted
Comments
Tejas Vaishnav 19-Oct-12 9:25am    
What value itemToTorrent array has. I think your itemToTorrent array is missing that value which your mainForm.TorrentsView.SelectedItems return. so please check that item value in your itemToToreent array.

1 solution

The error speaks for itself. The item you are looking for by key does not exist in the dictionary collection you are searching in.
Check the value of your keys in the debugger to make sure that they are what you think they are.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900