Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy ToolStripItem can't handle big numbers?
    primarykey
    data
    text
    <p>I have a recursive funcion that search for folders.</p> <pre><code> private int contFiles = 0; private List&lt;string&gt; GetFiles(string folder, string filter) { var files = new List&lt;string&gt;(); Action&lt;string&gt; getFilesInDir = null; getFilesInDir = new Action&lt;string&gt;(dir =&gt; { contFiles++; tslQuant.Text = contFiles.ToString(); //ToolStripItem try { // get all the files in this directory files.AddRange(Directory.GetFiles(dir, filter)); // and recursively visit the directories foreach (var subdir in Directory.GetDirectories(dir)) { getFilesInDir(subdir); } } catch (UnauthorizedAccessException uae) { Console.WriteLine(uae.Message); } }); getFilesInDir(folder); return files; } </code></pre> <p>The function increments contFiles and set that number to a ToolStripItem, but I'm Always getting "System.ArgumentOutOfRangeException".</p> <p><strong>How can I increase this value (up to 5000) and display in a TSI?</strong></p> <p>ERROR:</p> <p>System.ArgumentOutOfRangeException was unhandled Message="Index was out of range. It must be non-negative and less than the size of the collection. Parameter name: index"</p> <p>Source="mscorlib" ParamName="index" StackTrace: in System.Collections.ArrayList.get_Item(Int32 index) in System.Windows.Forms.ToolStripItemCollection.get_Item(Int32 index) in System.Windows.Forms.ToolStrip.OnPaint(PaintEventArgs e) in System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer) in System.Windows.Forms.Control.WmPaint(Message&amp; m) in System.Windows.Forms.Control.WndProc(Message&amp; m) in System.Windows.Forms.ToolStrip.WndProc(Message&amp; m) in System.Windows.Forms.StatusStrip.WndProc(Message&amp; m) in System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m) in System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) InnerException: </p> <h2>EDIT</h2> <p>After Reading up the whole code of the program, I notice that the funcion is being caled inside a Do_Work, so I'm using a </p> <pre><code>backgroundWorker2.ReportProgress((1)); </code></pre> <p>to report aaand everything is working.</p> <p><strong>I don't know WHY, but somehow, the toolStripItem can be accessed even inside a backgroundWorker, labels and others controls can't.</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload