Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a loop for loading file(s) into one array.

 

Everything works fine if my files are in correct location. This problem appears when one or more files are not there and my application has a fatal error.

 

I made a function for check if my files are there and if not the application is closed without that big error (msgbox)

 

It is possible to read my files and the files that don't exist to be with empty values like �0�?

 

This because all the values are used for a chart and even I don't have one day values I want to see the rest of files on my chart.

 

Thanks

  • *Experts*
Posted

If you check to see if a file exists, then it won't be hard to just fill an element of array with a zero.

'see if the file exists
If System.IO.FIle.Exists("path") Then
   'read the file or do whatever you want to do with it
   Dim reader As New System.IO.StreamReader("path")
   '....
Else 'file does not exist
   'add a zero to your array, im assuming you are using an ArrayList
   yourarray.Add(0)
End If

Is this what you are looking for?

:)

Posted

hi.

 

Thanks for your answer, but I made a function to see if the files is there, and if not, I write a file with my necessary name with 0 values.

 

But...I have another problem.... :(

 

My files are generated by a system (automatically). This system must generate 15 values like:

 

1 0.5

2 2.8

.......

15 2.36

 

it's possible that the system can't generate all the values, and maybe I will have this:

 

1 0.5

2

3 0.58

....

15 2.36

 

If this happens is bad because I receive a failure message like: Cast from string "" to type 'Decimal' is not valid. ..because I use some conversion tools.

 

It is possible to fill my array with empty values? ..

 

Thanks

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...