473,749 Members | 2,665 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help--My Array is too Big-----Help move to a .dat file?

Visual Studio .NET started complaing when the array was around 4000. I
found that if I pasted the array in via notepad then opened Visual Studio it
would work. Now my array is over 26,000 and Visual Studio just doesn't like
it. Everytime I open the prokect I get the following error:

"An Error occurred which the C# comipler is unable to report due to low
memory or possible heap corruption. It is recommended that you save all your
files, close and restart"

If I wait for about 60 seconds I can use the program as long as I stay out
of the class with that array (about 633kb).

So I think it's time to move the array out to another file. So Can anyone
help me out here? I am thinking a .dat file or any other file that a user
can't simply open and read would be my first choice. Else I wopuld resort to
a plain old text file.
Nov 16 '05 #1
15 1743


Why not use an Excel Spreadsheet? It will address much
the same logic as an array and you may be able to use the
spreadhseet functions too.
-----Original Message-----
Visual Studio .NET started complaing when the array was around 4000. Ifound that if I pasted the array in via notepad then opened Visual Studio itwould work. Now my array is over 26,000 and Visual Studio just doesn't likeit. Everytime I open the prokect I get the following error:
"An Error occurred which the C# comipler is unable to report due to lowmemory or possible heap corruption. It is recommended that you save all yourfiles, close and restart"

If I wait for about 60 seconds I can use the program as long as I stay outof the class with that array (about 633kb).

So I think it's time to move the array out to another file. So Can anyonehelp me out here? I am thinking a .dat file or any other file that a usercan't simply open and read would be my first choice. Else I wopuld resort toa plain old text file.

Nov 16 '05 #2
That is a viable solution. In fact I maintain my ARRAY lists in an Excel
sheet prior to importing them into the program. I originally imported them
to make it one stand alone .exe file. Now it seems to out growing that. So
the thought of an external file comes to mind. A Excel file would yeild much
the same results as a .txt. or .csv. I though of the .dat file because all
the ones I've seen associated with programs you can't simply open and
read/modify.
An Excel file and the others mentiod would be open to the user. I have
seen many programs that have a few program files, then they update the .dat
files when new info comes out. I always liked this approach.
Nov 16 '05 #3
What about an XML file?

"Yogi_Bear_ 79" <IT*****@spamfr ee.com> wrote in message
news:wN******** ************@co mcast.com...
That is a viable solution. In fact I maintain my ARRAY lists in an Excel
sheet prior to importing them into the program. I originally imported them to make it one stand alone .exe file. Now it seems to out growing that. So the thought of an external file comes to mind. A Excel file would yeild much the same results as a .txt. or .csv. I though of the .dat file because all
the ones I've seen associated with programs you can't simply open and
read/modify.
An Excel file and the others mentiod would be open to the user. I have
seen many programs that have a few program files, then they update the ..dat files when new info comes out. I always liked this approach.

Nov 16 '05 #4
Yogi_Bear_79 <IT*****@spamfr ee.com> wrote:
Visual Studio .NET started complaing when the array was around 4000. I
found that if I pasted the array in via notepad then opened Visual Studio it
would work. Now my array is over 26,000 and Visual Studio just doesn't like
it. Everytime I open the prokect I get the following error:

"An Error occurred which the C# comipler is unable to report due to low
memory or possible heap corruption. It is recommended that you save all your
files, close and restart"

If I wait for about 60 seconds I can use the program as long as I stay out
of the class with that array (about 633kb).

So I think it's time to move the array out to another file. So Can anyone
help me out here? I am thinking a .dat file or any other file that a user
can't simply open and read would be my first choice. Else I wopuld resort to
a plain old text file.


What's it an array of? You might find that BinaryReader/BinaryWriter is
the way to go. If the array is pre-defined (as presumably it is), you
could embed the content into the assembly to make it easier for the
user.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #5
What's it an array of? You might find that BinaryReader/BinaryWriter is
the way to go. If the array is pre-defined (as presumably it is), you
could embed the content into the assembly to make it easier for the
user.

The array is a predefined list of web sites, and another of ActiveX CLSIDs.

The Array of web sites is over 26,000 elements, and the ActiveX is over
1300. When you say I could embed the content into the assembly, what does
that mean? Does it mean I could use binary to represent my arrays, and
compile it into the executable, thus keeping my single file? I would love
that. As my arrays grew my program grew from 233kb to 1.4Mb, so with the
advent of Visual Studio complaining about my large class, I thought it best
to move the arrays out of the compiled program, and manage them in seperate
files. But If I went that route I'd like to see them "encoded" for lack of a
better word. Ultimatly I would rather leave them within the compiled .exe
tho
Nov 16 '05 #6
I would think an .xml file would also work, but I beleive it has the same
pros & cons as the other files listed below?
What do you think?
"christian strevel" <cs_at_intellek t.ws> wrote in message
news:u6******** ******@TK2MSFTN GP14.phx.gbl...
What about an XML file?

"Yogi_Bear_ 79" <IT*****@spamfr ee.com> wrote in message
news:wN******** ************@co mcast.com...
That is a viable solution. In fact I maintain my ARRAY lists in an Excel
sheet prior to importing them into the program. I originally imported

them
to make it one stand alone .exe file. Now it seems to out growing that.

So
the thought of an external file comes to mind. A Excel file would yeild

much
the same results as a .txt. or .csv. I though of the .dat file because all the ones I've seen associated with programs you can't simply open and
read/modify.
An Excel file and the others mentiod would be open to the user. I have
seen many programs that have a few program files, then they update the

.dat
files when new info comes out. I always liked this approach.


Nov 16 '05 #7
Yogi_Bear_79 <IT*****@spamfr ee.com> wrote:
What's it an array of? You might find that BinaryReader/BinaryWriter is
the way to go. If the array is pre-defined (as presumably it is), you
could embed the content into the assembly to make it easier for the
user.


The array is a predefined list of web sites, and another of ActiveX CLSIDs.

The Array of web sites is over 26,000 elements, and the ActiveX is over
1300. When you say I could embed the content into the assembly, what does
that mean? Does it mean I could use binary to represent my arrays, and
compile it into the executable, thus keeping my single file? I would love
that. As my arrays grew my program grew from 233kb to 1.4Mb, so with the
advent of Visual Studio complaining about my large class, I thought it best
to move the arrays out of the compiled program, and manage them in seperate
files. But If I went that route I'd like to see them "encoded" for lack of a
better word. Ultimatly I would rather leave them within the compiled .exe
tho


What you'd do is create a text file (or something similar) and put that
in your VS.NET project as a resource with a property telling it to make
it an embedded resource. You'd then need to use
Assembly.GetMan ifestResourceSt ream to open the file, read it into your
array (or ArrayList) at runtime and then you're "good to go".

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #8
>> What you'd do is create a text file (or something similar) and put that
in your VS.NET project as a resource with a property telling it to make
it an embedded resource. You'd then need to use
Assembly.GetMan ifestResourceSt ream to open the file, read it into your
array (or ArrayList) at runtime and then you're "good to go".


Before I begin, let me thank you for your time. I am a self learned
programmer, I do it to streamline some of my workload as a systems
administrator. So I am on a slow curve, as I use the net, books, and NG to
learn. I have not taken any classes.

Ok. I created and set to embedded a .txt file called Sites.txt

My original program was setup like this

private string [] sResSitesList= {"008i.com", "008k.com", "00hq.com",
"0190-dialer.com"};
public string []strResSitesList
{
get { return sResSitesList; }
set { sResSitesList = value; }
}

Then I would access the Array from another class:
foreach(string x in strResSitesList )
{
using (RegistryKey Key = Registry.LocalM achine.CreateSu bKey( x )
{
Key.SetValue ("*", Convert.ToInt32 (00000004));
}

}

How do I now access my list from the .txt file, and if you could explain the
benifit of this method I would appriciate it. I usually need code examples
to learn new ideas, so I can see how it works..I am also willing to read, I
am doing google searches as we speak

Nov 16 '05 #9
Yogi_Bear_79 <IT*****@spamfr ee.com> wrote:
What you'd do is create a text file (or something similar) and put that

in your VS.NET project as a resource with a property telling it to make
it an embedded resource. You'd then need to use
Assembly.GetMan ifestResourceSt ream to open the file, read it into your
array (or ArrayList) at runtime and then you're "good to go".


Before I begin, let me thank you for your time. I am a self learned
programmer, I do it to streamline some of my workload as a systems
administrator. So I am on a slow curve, as I use the net, books, and NG to
learn. I have not taken any classes.

Ok. I created and set to embedded a .txt file called Sites.txt

My original program was setup like this

private string [] sResSitesList= {"008i.com", "008k.com", "00hq.com",
"0190-dialer.com"};
public string []strResSitesList
{
get { return sResSitesList; }
set { sResSitesList = value; }
}

Then I would access the Array from another class:
foreach(string x in strResSitesList )
{
using (RegistryKey Key = Registry.LocalM achine.CreateSu bKey( x )
{
Key.SetValue ("*", Convert.ToInt32 (00000004));
}

}

How do I now access my list from the .txt file, and if you could explain the
benifit of this method I would appriciate it. I usually need code examples
to learn new ideas, so I can see how it works..I am also willing to read, I
am doing google searches as we speak


Well, you'd read it like a normal text file, so you'd use something
like:

ArrayList resourceSites = new ArrayList();

using (Stream stream=GetType( ).Assembly.GetM anifestResource Stream(...))
{
using (StreamReader reader = new StreamReader(st ream))
{
string line;
while ( (line=reader.Re adLine()) != null)
{
resourceSites.A dd(line);
}
}
}

Then you'd need to create the text file, put it into the solution, and
make the build action "embedded resource". Then just make sure that you
get the right name in the call to GetManifestReso urceStream, and it'll
all work.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #10

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

Similar topics

11
3338
by: Jeevan | last post by:
Hi, I have some data which I am getting from a socket. I am currently storing the data in an array (so that future reading of the data will be fast as it will be in RAM instead of hard disk). Is there any way I can treat this array as a file i.e. can I apply file operations (like fopen, fscanf etc) on this array without having to write the data into a physical file and then read
9
4330
by: steph_de_marseille | last post by:
I would like to write a x array in a file. If the array has a small numbers of columns I know I can use a loop like: int i,j; double array; FILE *file1; file1=fopen("data.dat","w"); for(i=0;i<50;i++){
1
940
by: Mike | last post by:
'Declare array to load file Dim mstrCarinfo(9, 3) As String 'Declare streamreader Private datvehiclelookup As StreamReader Private Sub Loadarray() ' Load Array Dim intCol As Integer Dim intRow As Integer
2
2311
by: Speed | last post by:
Could you please tell me which is the most efficient of way writing a BOOLEAN array to a file. Thanks a ton. Speed
2
6422
by: coolindienc | last post by:
Hello, I have tried to fill array from a file and sort it by first column and then by second column. However, I am getting several errors. Please someone show me where is/are my mistake/s. Below are my file and code. Thanks a million in advance. Text file 2 5 1050 5 17 1200 3 12 1225 2 23 1300 3 6 1140
12
22846
by: fanoftvb | last post by:
Hi, i would like to move a selected files to a folder using vb.net. I currently have this code If File.Exists("C:\Documents and Settings\055949x\transfer\text.txt") And Not File.Exists("C:\Documents and Settings\055949x\transfer\text.txt") Then File.Move("C:\Documents and Settings\055949x\transfer\text.txt", "C:\Documents and Settings\055949x\Desktop\AES file\transfer\text.txt") Label1.Text = ("File...
0
2490
by: prasenjit2007 | last post by:
I have a main form for inputing the (to/from/mesg/file) with the following code:- <html> <body> <table> <tr> <td>To:</td> <td><input type="text" name="to" size="50" value="pras_sandilya@rediffmail.com"></td> </tr>
2
7007
by: susinthaa | last post by:
Hi, How to copy an array to a file? I tried the File :: copy, But the array is not copying to the file. @susi=$telnet->cmd("logtail"); $newfile = "$movie/$song/$file"; copy(@susi,$newfile) or die "File cannot be copied.";
5
8959
by: jslee99a | last post by:
hello I use visual basic 6.0. I want to read file twice. First i read file then i don't know how to move the file pointer to the start point. i don't want to close file and reopen. example)
0
1058
by: naivewisdom | last post by:
For a lengthy program which would be in no way helpful to discribe, I need to populate a three dementional array from a file and overwrite the file with the modefied arraylist later. The three dementional arraylist will always be in the form Integer and the file should have one number on each line which corresponds to a place in the array. For some reason my code is not populating the array at all. Here is the portion of the code which populates...
0
8833
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
9568
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...
0
9389
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9335
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
8257
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...
0
6079
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4709
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...
0
4881
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2794
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.