473,685 Members | 3,008 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1836
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.co m

"Geoff Cox" <ge*******@remo ve-this.freeuk.com > wrote in message
news:pr******** *************** *********@4ax.c om...
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.c om> 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.c om> 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*******@yaho o.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
2024
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 still getting the hang of javascript, and I've searched the web, but
0
1056
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. Thanks for any help Shepard
4
4875
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 create a web service in c# using paradox data. The data is stored locally on my development machine with IIS also installed. Web services are working to the point where I can return strings and ints using Access2000 data but whenever I try and...
3
5762
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 drive onto a USB External Hard Drive. I have to assume I also copied the data. I
0
1494
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 External Data -->New Database Query. Last week I connected quickly and reliably. As of Monday morning, It now takes 7.5 minutes to connect to the DB and all the while the hard disk is spinning constantly. Another tool no longer connects at all with...
3
7805
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 residing in a different translation unit, then the current translation unit was simply oblivious to it and had no way of accessing it. Any time the function name was mentioned in the current translation unit, it referred to the "static" one which...
21
3891
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 applies in this case though: #include <limits.h> unsigned foo(void) { static const union { unsigned char str;
1
1796
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 file provided by an external data provider. I am proposing to add a button to one of the forms in my application to perform this validation and then pop up a message box indicating whether the flat file is valid or not. This is in preference to...
0
1012
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 on the 'other' server, and I also included the metacommand Security.Permissions.FileIOPermission(Security.Permissions.SecurityActio n.Assert)
0
8570
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8504
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9043
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8758
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7584
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6431
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4299
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2936
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.