473,395 Members | 1,504 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,395 software developers and data experts.

accessing data in external file?

Hello,

Just starting C# with MS Visual Studio Pro 2005 ...

How do I access array data which is in an external file? I would
prefer to have it there to make the code less cluttered..

Thanks

Geoff
Jan 13 '06 #1
4 1820
Geoff,

How are you storing the data in the file? Can you provide a sample of
the file?

The first recommendation would be to use the FileStream class to open
the file for reading. Once you have that, you can use the BinaryReader
class to read primary type information from the file (assuming you wrote the
file in a format that the BinaryReader can understand).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Geoff Cox" <ge*******@remove-this.freeuk.com> wrote in message
news:pr********************************@4ax.com...
Hello,

Just starting C# with MS Visual Studio Pro 2005 ...

How do I access array data which is in an external file? I would
prefer to have it there to make the code less cluttered..

Thanks

Geoff

Jan 13 '06 #2
On Fri, 13 Jan 2006 10:40:13 -0500, "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.com> wrote:
Geoff,

How are you storing the data in the file? Can you provide a sample of
the file?
Nicholas,

The idea is to have a series of statements, the left hand side and the
right hand side statements, for each of several situations, eg

var lhs_0 = new Array(8)
lhs_0[0]="situation 1 lhs statement 1";
lhs_0[1]="situation 1 lhs statement 2";
etc

var rhs_0 = new Array(8)
rhs_0[0]="situation 1 rhs statement 1";
rhs_0[1]="situation 1 rhs statement 2";
etc

var lhs_1 = new Array(8)
lhs_1[0]="situation 2 lhs statement 1";
lhs_1[1]="situation 2 lhs statement 2";
etc

var rhs_1 = new Array(8)
rhs_1[0]="situation 2 rhs statement 1";
rhs_1[1]="situation 2 rhs statement 2";
etc

Cheers

Geoff



The first recommendation would be to use the FileStream class to open
the file for reading. Once you have that, you can use the BinaryReader
class to read primary type information from the file (assuming you wrote the
file in a format that the BinaryReader can understand).

Hope this helps.


Jan 13 '06 #3
Geoff,
the "var" keyword doesn't come out until C# 3.0, so we can only assume that
this is Javascript. How about storing your data in some sort of CSV format
with delimiters which would be easier to parse?
Or, you could make the array a member of a serializable class, serialize the
class to a byte array using the BinaryFormatter class, and save it as a
binary file. This would be much easier to read back and deserialize into the
class.
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Geoff Cox" wrote:
On Fri, 13 Jan 2006 10:40:13 -0500, "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.com> wrote:
Geoff,

How are you storing the data in the file? Can you provide a sample of
the file?


Nicholas,

The idea is to have a series of statements, the left hand side and the
right hand side statements, for each of several situations, eg

var lhs_0 = new Array(8)
lhs_0[0]="situation 1 lhs statement 1";
lhs_0[1]="situation 1 lhs statement 2";
etc

var rhs_0 = new Array(8)
rhs_0[0]="situation 1 rhs statement 1";
rhs_0[1]="situation 1 rhs statement 2";
etc

var lhs_1 = new Array(8)
lhs_1[0]="situation 2 lhs statement 1";
lhs_1[1]="situation 2 lhs statement 2";
etc

var rhs_1 = new Array(8)
rhs_1[0]="situation 2 rhs statement 1";
rhs_1[1]="situation 2 rhs statement 2";
etc

Cheers

Geoff



The first recommendation would be to use the FileStream class to open
the file for reading. Once you have that, you can use the BinaryReader
class to read primary type information from the file (assuming you wrote the
file in a format that the BinaryReader can understand).

Hope this helps.


Jan 13 '06 #4
On Fri, 13 Jan 2006 09:50:02 -0800, "Peter Bromberg [C# MVP]"
<pb*******@yahoo.nospammin.com> wrote:
Geoff,
the "var" keyword doesn't come out until C# 3.0, so we can only assume that
this is Javascript. How about storing your data in some sort of CSV format
with delimiters which would be easier to parse?
Peter,

Yes, you are correct, I am trying to make a C# version of some
javascript code. At the time I could not find a slider control. I was
using Visual Web Developer 2005 Express at that time.
Or, you could make the array a member of a serializable class, serialize the
class to a byte array using the BinaryFormatter class, and save it as a
binary file. This would be much easier to read back and deserialize into the
class.


Could you point me at info re how to make the array a member of a
serializable class etc?

Cheers

Geoff

Jan 13 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: John B. | last post by:
In an effort to turn a little more a module with my pages, I would like to turn my internal javascripts into an external javascript files to supply the information onto a web page. I...
0
by: ShepardBerry | last post by:
Accessing IE HTML Data From External Application Does anyone know how to get the data from an IE window. I need to be able to read the text box data in a browser window from another application....
4
by: Eugen Walcher | last post by:
Hello all, I've tried posting this same question on other newsgroups with no luck. This group seems to have a lot more activity so I apologize if you have seen it before. I'm trying to...
3
by: eieiohh | last post by:
MySQL 3.23.49 PHP 4.3.8 Apache 2.0.51 Hi All! Newbie.. I had a CRM Open Source application installed and running. Windows Xp crashed. I was able to copy the contents of the entire hard...
0
by: jd_12345 | last post by:
Windows XP Pro SP2 Excel 2003 SP2 IBM DB2 Personal Edition accessing a DB2 database on an AIX server via the DB2 ODBC driver I am accessing an external DB via MS Excel using Data-->Import...
3
by: Frederick Gotham | last post by:
Back in the day, if you wanted a function to be self-contained within a translation unit, you defined the function as "static". If there were an external linkage function by the same name...
21
by: Hallvard B Furuseth | last post by:
Is the code below valid? Generally a value must be accessed through the same type it was stored as, but there is an exception for data stored through a character type. I'm not sure if that...
1
by: Lyndon | last post by:
Hi all, I am developing an Access database application that requires some additional, non-database related functionality. This additional functionality is essentially to validate a flat text...
0
by: Tom | last post by:
I have a Windows Service that I wrote in VB.NET (2005). I what the OnStart method to be able to 'read' an external file - in this case, a file on another server. The file is on a shared folder...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.