473,407 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Index Error on file

91
When I run this if the file trying to be renamed / moved is the current file running to skip it. However I get an error that says
Expand|Select|Wrap|Line Numbers
  1. Index was out of range. Must be non-negative and less than the size of the collection
However I don't know where it would be trying to access the collection UpdatedFiles over the array size.

Expand|Select|Wrap|Line Numbers
  1. try
  2.                 {
  3.                     lblStatus.Text = "Installing...";
  4.                     Application.DoEvents();
  5.                     for (int i = 0; i <= UpdatedFiles.Count; i++)
  6.                     {
  7.                         //MessageBox.Show(UpdatedFiles[i].ToString().ToLower() + "!=" + thisFile.ToLower());
  8.                         if (!UpdatedFiles[i].ToString().ToLower().Equals(thisFile.ToLower()))
  9.                         {
  10.                             lblFile.Text = UpdatedFiles[i].ToString();
  11.                             Application.DoEvents();
  12.                             if (File.Exists(UpdatedFiles[i].ToString()))
  13.                             {
  14.                                 File.Delete(UpdatedFiles[i].ToString());
  15.                             }
  16.                             File.Move("~" + UpdatedFiles[i].ToString(), UpdatedFiles[i].ToString());
  17.                         }                    
  18.                     }
  19.                 }
  20.                 catch(SystemException ex)
  21.                 {
  22.                     MessageBox.Show(ex.Message + " (" + nodeFile["FileName"].InnerText + ")",
  23.                         "An Error Occurred During Installation!",
  24.                         System.Windows.Forms.MessageBoxButtons.OK,
  25.                         System.Windows.Forms.MessageBoxIcon.Error,
  26.                         System.Windows.Forms.MessageBoxDefaultButton.Button1);
  27.                     //MessageBox.Show(_text);
  28.                 }
  29.  
Sep 12 '08 #1
2 1056
arggg
91
Nevermind I found it. The FOR should of been i < UpdatedFiles.Count()
Sep 12 '08 #2
Plater
7,872 Expert 4TB
I was too late at saying that. Yes, the index is zero based so going to <=length will go over the number of indexes
Sep 12 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Andrew Dalke | last post by:
Is there an author index for the new version of the Python cookbook? As a contributor I got my comp version delivered today and my ego wanted some gratification. I couldn't find my entries. ...
12
by: Tuhin Kumar | last post by:
Hi, Oracle give the error ORA-01418 when I try to do the following; Create unique index t1_pk on TABLE1(EntryId DESC) ; If the I try to add primary key Contraint using the above index t1_pk...
0
by: Jean Hagen | last post by:
I'm trying to write a script to weekly remove MySQL logs, the general, error and binary log files. Following the MySQL documentation, I've written a script that moves all current log files, then...
0
by: Eugene | last post by:
Hello all, I've been trying to figure this out for a few days now, and still have no clue what's going on... I have a few related tables in MS Access (Clients, Cars, Sales), and a datagrid,...
2
by: kscdavefl | last post by:
When I run the following code: private void applicationPermissionGrid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { if (e.Item.ItemType ==...
0
by: JSantora | last post by:
Essentially, InsertAT is broken! For the past couple of hours, I've been getting this "Parameter name: '-2147483550' is not a valid value for 'index'." error. Apparently, its caused by having...
12
by: comp.lang.php | last post by:
index.php: // STUFF // STEP 1: imagecreatetruecolor ONLY IF GD 2.0+ SUPPORTED AND FOUND if ($this->isSuccessful && !$hasMogrified && $image && !$newImage &&...
0
by: ssims | last post by:
I've got a GridView that's sorted by a stored procedure with ROW_NUMBER: PROCEDURE dbo.GetCalendarsByStatusIDPaged ( @startRowIndex int, @maximumRows int, @statusID int ) AS
14
by: Gert Cuykens | last post by:
Is there a difference between <code> class HelloWorld: def index(self): index.exposed = True return "Hello world!" </code> and
2
by: mmr315 | last post by:
i write 2 php files for uploading file ,it is giving error like Undefined index: C:\\Apache2.2 in C:\\Apache2.2\\htdocs\\upload_file.php on line 11, upload.php -------------------- <html>...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.