|
Hi,
IMO it would be faster to interrogate the file system only once (with the most restricting filter that still passes everything of interest) and then either modify the collection (by removing the unwanted entries, or creating a new one that only contains the wanted ones, i.e. applying a software filter once),
or best of all performance-wise just use the one collection and skip the unwanted files while enumerating.
Also going to the file system twice may return inconsistent information, in between the two calls some files may have been added and removed!
Luc Pattyn [Forum Guidelines] [My Articles]
I use ListBoxes for line-oriented text output (not TextBoxes), and PictureBoxes for pictures (not drawings).
modified on Friday, June 10, 2011 12:21 PM
|
|
|
|
|
Smashing, Luc. Your last point is excellent; I hadn't thought of it.
Yep, getting all files and deleting the ones you don't need directly from the collection returned is likely the best way to do it.
Cheers,
Vıkram.
I don't suffer from insanity, I enjoy every moment of it.
|
|
|
|
|
If only .NET allowed passing regexes for the search pattern... ( I know it uses FindNextFile internally, just wishing )
|
|
|
|
|
S. Senthil Kumar wrote: If only .NET allowed passing regexes
Wouldn't interest me; I'm not that fond of regex stuff: it gets very complex and slow pretty soon.
Here are three things I would appreciate:
1. getting the results from GetFiles() and the like one by one, without needing the possibly huge
array to hold the collection. Most of the time it is GetFiles() followed by foreach anyway.
2. passing a filter delegate to some of those GetMany methods.
3. if they have to return everything at once, get it in a real collection (say a List) rather than an
array, so we can operate on them (mostly remove some!).
Luc Pattyn [Forum Guidelines] [My Articles]
I use ListBoxes for line-oriented text output (not TextBoxes), and PictureBoxes for pictures (not drawings).
modified on Friday, June 10, 2011 12:21 PM
|
|
|
|
|
Luc Pattyn wrote: if they have to return everything at once, get it in a real collection (say a List) rather than an
array, so we can operate on them (mostly remove some!).
That will be available in .Net Framework 4.0
|
|
|
|
|
i was able to ignore certain Files but i have a problem with Duplicates. My code looks like this
DirectoryInfo dir = new DirectoryInfo(@"C:\DATABASES\");<br />
<br />
FileInfo[] files = dir.GetFiles();<br />
<br />
foreach (FileInfo file in files)<br />
{<br />
<br />
if (file.Extension != ".mdf" && file.Extension != ".ldf")<br />
{<br />
<br />
cmbrestore.Items.Add(Convert.ToString(file.Name));<br />
}<br />
}
Thanks
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswam@its.co.za
|
|
|
|
|
cmbrestore.Items.Add(file.Name.ToString().Remove(LastIndexOf(file.Extension))
Pseudocode, so won't compile - but you get the general idea
I are troll
|
|
|
|
|
You might also consider creating your own List<> descendant class that does not allow duplicates, override the Add , Insert methods etc., load your files into an instance of your List<> class and set that as the DataSource to your dropdown.
Henry Minute
If you open a can of worms, any viable solution *MUST* involve a larger can.
|
|
|
|
|
Thanks i was able to remove the Duplicates with the Following Code
private static void RemoveDuplicateItems(DropDownList ddl)
{
for (int i = 0; i < ddl.Items.Count; i++)
{
ddl.SelectedIndex = i;
string str = ddl.SelectedItem.ToString();
for (int counter = i + 1; counter < ddl.Items.Count; counter++)
{
ddl.SelectedIndex = counter;
string compareStr = ddl.SelectedItem.ToString();
if (str == compareStr)
{
ddl.Items.RemoveAt(counter);
counter = counter - 1;
}
}
}
}
Thank you
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswam@its.co.za
|
|
|
|
|
Hi All,
Can You help me to set the paper size on crystal report."Avery Labels L 7160(63.5*38.1*21)" at design time.Is this Possible?
Thanks
|
|
|
|
|
|
I am creating a crystal report from C# dot net(windows), as of now i found tutorial and books to do that by taking the records from the data base tables.
Now what i have to do is that to print the report from the spooled datatable, ie the record from the datatable,
how to pass the datatable as a parameter.
as of now from the data base,
myreport rpt = new myreport();
crystalreportviewer1.reportsource= rpt,
this is working fine, and printing the records from the data base table.
now i have to pass the data table to the report?
how to do that
waiting for reply.
|
|
|
|
|
Bold text is used to emphasise specific words. If you use it on all text it only makes it harder to read.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
set the datasource of the report to your datatable.
rpt.datasource=datatable
On a side note:
'Hello peoples' = not a good subject line
And like Guffa said all bold text doesn't help, it only makes it harder to read
|
|
|
|
|
Guys,
sorry after typing the subject when i press enter
tag came and i didnt noticed that,
after posting only i noticed and it was in bold, and when i try to change that net connection got down.
sorry,...
|
|
|
|
|
I have created the report using the dataset, inside that datatable having one column.
myrpt rpt = new myrpt();
but here as you told rpt.datasource is not comming for me,
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CareVoyant.DAL.Helper;
using CareVoyant.Sys.Configuration;
using CareVoyant.BLL.Billing.Claims;
using CareVoyant.DAL.Billing.Claims;
using CareVoyant.BLL.Helper;
//using System.Xml;
//using System.IO;
using CareVoyant.BLL.Billing.ClaimsEditCheck;
using System.Data.Sql;
using System.Data.SqlClient;
am i missing any namespace or refference??
awaiting for your reply.
|
|
|
|
|
My mistake it should be:
rpt.SetDataSource(datatable)
|
|
|
|
|
Hi,
This is on C# Windows application, I want to build Caching mechanism generally that need to store some files and send back to me when i ask. Is there any good build in mechanism in C# or We need to use Enterprise Library to get this done?
Thanks
|
|
|
|
|
You can use the ASP.NET caching in WinForms or anywhere in .NET by referencing System.Web.dll
|
|
|
|
|
Dear Team,
I created two different threads and by using dataadapter i filled two different datasets. which have no relations among them and i want to bind/merge the two dataset into single dataset and bind them to the gridview.
private void button1_Click(object sender, EventArgs e)
{
Thread thread1 = new Thread(new ThreadStart(Procedure1));
Thread thread2 = new Thread(new ThreadStart(Procedure2));
//Thread thread3 = new Thread(new ThreadStart(Procedure3));
thread1.Start();
thread2.Start();
loaddata();
}
private void Procedure1()
{
OracleConnection con = new OracleConnection(ConnectString);
OracleCommand command = new OracleCommand(" select * from CIHOLDDETAILS", con);
OracleDataAdapter da = new OracleDataAdapter(command);
//da.TableMappings.Add("Table1","Holddetails");
da.Fill(ds,"HOLDDETAILS");
//da.Fill(dt);
//dt = ds.Tables[0].Copy();
}
private void Procedure2()
{
OracleConnection cn = new OracleConnection(ConnectString);
OracleCommand cmd = new OracleCommand(" select * from CIINSPECTIONREPORTS", cn);
OracleDataAdapter orda = new OracleDataAdapter(cmd);
orda.Fill(ds2, "CIINSPECTIONREPORTS");
//dt2 = ds2.Tables[0].Copy();
}
private void loaddata()
{
ds3.Merge(ds);
ds3.Merge(ds2);
dataGridView1.DataSource = ds3;
}
here i tried to merge the dataset but it is giving error as :Collection was modified; enumeration operation might not execute.
i think becouse of different datatypes and different table it is giving. but how to handile it
or there any alternative way of doing this
please help me out in this problem .
Thanx in Advance
|
|
|
|
|
I need to write an arrays by coulms
i have the following array
a1={1,2,3,4,5,6}
a2={7,8,9,10,11}
.
.
.
.
an={10,11,12,13,14,15}
and i want to print it as
1 7 ... 10
2 8 ... 11
3 9 ... 12
4 10 ... 13
5 11 ... 14
6 12 ... 15
|
|
|
|
|
Aren't you really really able to figure out how to accomplish such task (you know array elements may be accessed by indexes...)?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
what about this code? I'm supposing that you have all arrays in a list called aListOfArrays.
int iColumnCount = aListOfArrays[0].length;
for(int iCurColumn = 0; iCurColumn < iColumnCount; iCurColumn++) {
for(int iCurArray = 0; iCurArray < aListOfArrays.Count; iCurArray++) {
System.out.print(" " + aListOfArrays[iCurArray][iCurColumn].ToString());
}
System.out.println();
}
Does this help you?
Regards
Sebastian
|
|
|
|
|
You helped him in doing his homework.
Now I am expecting another question for converting java into c#
*jaans
|
|
|
|
|
Shame on me
I'm expecting a question like: "Now I have to add all numbers together..."
|
|
|
|