What to use for file contents....

  • Thread starter Thread starter Denis Briel
  • Start date Start date
D

Denis Briel

hi everyone,

i have a minor prob and am not sure how to solve this.

What are we coming from?
Well, there are several template files inside a folder. these template
files have different names, like "DBCommonManager.cs" or
"%TABLE%EntityTable.cs", where "%TABLE%" is replaced during the work
with the file. Inside the the files, we have C# source code in which
we have to replace certain parts with variable contents.

What do we want to do?
We want to load the filenames dynamically into an ArrayList. For this
we have a DirectoryInfo object. Here's the source:

public ArrayList GetFilenames(string startpath){
try{
mPath = startpath + "/dsfiles/";
DirectoryInfo Sources = new DirectoryInfo(mPath);
ICollection ExistingFileNames = Sources.GetFiles();
mFileNames.AddRange(ExistingFileNames);
return mFileNames;
} catch (Exception e){
throw new Exception(e.Message);
}
}

Now we want to load the files contents into something. ;)
And here is my problem, i don't know what to load those contents into.
Best would be somekind of multidimensional array. But since it is not
easy to change an arrays size in runtime, i'm not sure if this is such
a good idea after all, because i have no clue, how many lines these
files contain. And since i need one element per line, i don't want to
size the arrays to 20000 in the beginning.

If anyone has any suggestions, i would be very thankfull!

Yours,
Denis
 
Now we want to load the files contents into something. ;)
And here is my problem, i don't know what to load those contents into.
Best would be somekind of multidimensional array. But since it is not
easy to change an arrays size in runtime, i'm not sure if this is such
a good idea after all, because i have no clue, how many lines these
files contain. And since i need one element per line, i don't want to
size the arrays to 20000 in the beginning.

Is the System.Collections.Specialized.StringCollection internally also
an array or a linked list?
If it is a linked list I would advise you to use that one! LL's have
less performance issues with adding/removing elements than resizing
arrays has.
 
Back
Top