I am looking for a way to combine 2 string arrays.
I am trying to get a list of files from 2 directories and combine them:
string[] strFiles;
string[] strFiles2;
strFiles = Directory.GetFiles(Settings.ArchiveFilePath, "*.*");
strFiles2 = Directory.GetFiles(Settings.ExceptionFilePath,
"*.*");
One way I was looking at was to copy them into a string collection:
List<stringsarray = new List<string>();
How would I get the string arrays into the collection? Do I need to do 2
loops and move them in one at a time?
Thanks,
Tom 6 3428
On Fri, 25 Jul 2008 14:30:13 -0700, tshad <ts***@dslextreme.comwrote:
[...]
How would I get the string arrays into the collection? Do I need to do 2
loops and move them in one at a time?
See List.AddRange(): http://msdn.microsoft.com/en-us/library/z883w3dc.aspx
For example:
List<stringsarray = new List<string>(strFiles.Length +
strFiles2.Length);
sarray.AddRange(strFiles);
sarray.AddRange(strFiles2);
Pete
tshad wrote:
I am looking for a way to combine 2 string arrays.
I am trying to get a list of files from 2 directories and combine them:
string[] strFiles;
string[] strFiles2;
strFiles = Directory.GetFiles(Settings.ArchiveFilePath, "*.*");
strFiles2 = Directory.GetFiles(Settings.ExceptionFilePath,
"*.*");
One way I was looking at was to copy them into a string collection:
List<stringsarray = new List<string>();
How would I get the string arrays into the collection? Do I need to do 2
loops and move them in one at a time?
List<stringsarray = strFiles.Concat(strFiles2).ToList();
Alun Harford
Both look pretty good.
Thanks,
Tom
"Alun Harford" <de*****@alunharford.co.ukwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
tshad wrote:
>I am looking for a way to combine 2 string arrays.
I am trying to get a list of files from 2 directories and combine them:
string[] strFiles; string[] strFiles2;
strFiles = Directory.GetFiles(Settings.ArchiveFilePath, "*.*"); strFiles2 = Directory.GetFiles(Settings.ExceptionFilePath, "*.*");
One way I was looking at was to copy them into a string collection:
List<stringsarray = new List<string>();
How would I get the string arrays into the collection? Do I need to do 2 loops and move them in one at a time?
List<stringsarray = strFiles.Concat(strFiles2).ToList();
Alun Harford
Spoke a little too soon.
Apparently, strFiles.Concat(...) isn't valid.
Do I need another using statement other than using System?
Thanks,
Tom
"tshad" <ts***@dslextreme.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Both look pretty good.
Thanks,
Tom
"Alun Harford" <de*****@alunharford.co.ukwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>tshad wrote:
>>I am looking for a way to combine 2 string arrays.
I am trying to get a list of files from 2 directories and combine them:
string[] strFiles; string[] strFiles2;
strFiles = Directory.GetFiles(Settings.ArchiveFilePath, "*.*"); strFiles2 = Directory.GetFiles(Settings.ExceptionFilePath, "*.*");
One way I was looking at was to copy them into a string collection:
List<stringsarray = new List<string>();
How would I get the string arrays into the collection? Do I need to do 2 loops and move them in one at a time?
List<stringsarray = strFiles.Concat(strFiles2).ToList();
Alun Harford
tshad wrote:
Spoke a little too soon.
Apparently, strFiles.Concat(...) isn't valid.
Do I need another using statement other than using System?
You need C# 3 for that one, and
using System.Linq;
Alun Harford
On Jul 26, 1:30*am, "tshad" <ts...@dslextreme.comwrote:
I am looking for a way to combine 2 string arrays.
I am trying to get a list of files from 2 directories and combine them:
* * * * * * string[] strFiles;
* * * * * * string[] strFiles2;
* * * * * * strFiles = Directory.GetFiles(Settings.ArchiveFilePath, "*.*");
* * * * * * strFiles2 = Directory.GetFiles(Settings.ExceptionFilePath,
"*.*");
One way I was looking at was to copy them into a string collection:
* * * * * * List<stringsarray = new List<string>();
How would I get the string arrays into the collection? *Do I need to do2
loops and move them in one at a time?
If you're okay with having array as a result, here's another one:
string[] sarray = new string[strFiles.Length + strFiles2.Length];
strFiles.CopyTo(sarray, 0);
strFiles2.CopyTo(sarray, strFiles.Length); This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Chris Mullins |
last post by:
I've spent a bit of time over the last year trying to implement RFC 3454
(Preparation of Internationalized Strings, aka 'StringPrep').
This RFC is also a dependency for RFC 3491...
|
by: mike |
last post by:
If I have 2 object arrays like:
var txtobj = theform.getElementsByTagName("input");
var selobj = theform.getElementsByTagName("select");
and i want to iterate over them I'd like to combine...
|
by: Don Starr |
last post by:
When applied to a string literal, is the sizeof operator supposed to return the size of the string
(including nul), or the size of a pointer?
For example, assuming a char is 1 byte and a char *...
|
by: Mr. Jingles |
last post by:
Hi, anyone have any thoughts on combining two 2-Dimensional arrays into one.
Thanx
|
by: ferraro.joseph |
last post by:
Hi,
I'm querying Salesforce.com via their AJAX toolkit and outputting query
results into a table. Currently, their toolkit does not possess the
ability to do table joins via their structured...
|
by: Jeff |
last post by:
I have two array:
var Array1=new Array();
Array1=,,];
Array1=,,];
var Array2=new Array();
Array2=,,];
|
by: =?Utf-8?B?U1MgbWFkaHU=?= |
last post by:
Hi,
I have two word files.
listprice.doc,product.doc
I converted each of the documents into bytes
byte bytedata - lisprice.doc
byte bytedata1-product.doc
I create a new array and copy both...
|
by: Ken Fine |
last post by:
This is a question that someone familiar with ASP.NET and ADO.NET DataSets
and DataTables should be able to answer fairly easily. The basic question is
how I can efficiently match data from one...
|
by: rodeored |
last post by:
I don't know what the official programming lingo is for this situation
but there probably is one.
I have arrays, which happen to be parsed urls, and I want to make one
big array with each subarray...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |