|
I was wondering about the implementation of StreamReader.
I have a big file it can be about 2 gigabytes.
In the constructor, I constructed the StreamReader with a big buffer.
The question is if I use ReadLine does it work only with the buffer until it ends and then loads a new buffer or does it work with the file every time ?
I need it to be the most optimized possible.
If it doesn't work this way, do you know how to work with files in C# that don't work with streams and that I can implement it alone ?
Thanks, Clint
|
|
|
|
|
Explain what you are trying to do, I think I may have a solution. In general, it helps to post a little background but just enough to give an idea of what is going on.
|
|
|
|
|
Ok, I have actually 2 files.
Every file is a text file.
Every file is built out of vectors which the first column contains the date and time of the line.
I need to merge the two files so that in a each time stamp I will have a united vector of both files.
for example :
File 1:
10/2/2000 10:00:00 10 20 30 40 50 60 70 80
10/2/2000 10:00:01 13 18 30 25 54 12 9 8
10/2/2000 10:00:02 30 40 2 3 5 8 9 9
File 2 :
10/2/2000 10:00:00.1 FunctionA
10/2/2000 10:00:00.15 FunctionA
10/2/2000 10:00:00.2 FunctionB
10/2/2000 10:00:00.4 FunctionB
10/2/2000 10:00:00.6 FunctionB
Merged File :
10/2/2000 10:00:01 13 18 30 25 54 12 9 8 2 3
This an example only for the time 10:00:01.
What I am doing taking the time, date and the rest of the vector from the first file.
I check between every interval in this case 10:00:00 and 10:00:01 what happend in the second file, FunctionA happend twice and FunctionB happend 3 times, therefore in the merged file the 2 3 are placed in the end.
I built a program that does that, but it takes a long time to merge the files.
I was wondering whether I should implement the reading somehow else.
Thank you for your help.
Clint.
|
|
|
|
|
Hi
What is your actual req ? I think Streamreader will get slow if handles with big files. so better use Filestream. It can create byte arrays according to file size.
Cheers
|
|
|
|
|
Navaneeth.K.N wrote: I think Streamreader will get slow if handles with big files. so better use Filestream.
Why do you think that?
A StreamReader uses a FileStream to read the file, it doesn't read the file itself.
---
b { font-weight: normal; }
|
|
|
|
|
I replied before about what actually I want to do.
Please read and if you can help return to me.
Thanks,
Clint
|
|
|
|
|
I have already read that, and I can not add anything to what I have already said without any specific information on how you handle the data. If there is performance problems, it's not likely to be because of the StreamReader.
---
b { font-weight: normal; }
|
|
|
|
|
I want to multiplication like orderqty*rate=amount in c# datagrid windows appliction without using any button control when the cursor goes to the fild of amount inthe datagrid it should multiply the values given in the field of orderqty,rate if you need more description me ask me through email cutegirl_doctor@yahoo.co.in
I am a software developer in
c# dotnet located in bangalore india
|
|
|
|
|
Keep this in the thread you already created. Don't post the question in other threads too.
---
b { font-weight: normal; }
|
|
|
|
|
I'm not sure how the StreamReader uses it's buffer, but if it has one I hardly think that it's not using it.
Anyway, the file system also buffers file reads. A file is read in blocks of at least one cluster at a time, and a cluster is normally something like 4 kiB or 8 kiB.
Furthermore the disk may also use read-ahead, which means that when you read a sector, a certain number of sectors following it will also be read and stored in the drive cache. That means that when the file system requests the next sector, it will already be in the cache, and no physical read is needed.
So unless you have extremely long lines in your file, the disk will not be accessed for every call to ReadLine. There are several layers of buffering and caching that are quite efficient, so unless you run into performance problems, you hardly need to worry about it.
---
b { font-weight: normal; }
|
|
|
|
|
I want the source code for doing calculation like sum,multilication in datagrid c# rows and i want to insert the datas from datagrid to sqlserver2000 please help me
|
|
|
|
|
I did'nt get your requirement regarding calculation...can you be specific as to what you need to do...?
regarding inserting data , you can do something like this
sqlConnection con = new SqlConnection(Connectinstring);
SqlCommand cmd ;
cmd.Connection = conn;
foreach(DataGridItem <name> in <yourdatagridname>.Items)
{
string qry = "insert into(column names)(<name>.Cells[int index] ,.........)";
cmd.CommandText = qry;
cmd.ExecuteNonQuery();
}
Hope this helps..
Thanks
|
|
|
|
|
I have two files that I want to merge.
File1.ini
[COMP]
comp1
[PORT]
3567
file2.ini
[COMP]
comp3
[PORT]
3561
I want to merge these two files to create a file3.ini
File1.ini
[COMP]
comp1
comp3
[PORT]
3567
3561
Any body has a sample code. Any help will be greatly appreciated
|
|
|
|
|
Use a streamreader and writer to append to file3.ini.
|
|
|
|
|
perhaps you should consider xml configuration for your software... it's much easier to manipulate xml files using .net classes in such case. you have plenty of articles about that on codeproject.
|
|
|
|
|
I did find several examples using XML, unfortunately, the application is hard coded to look for file1.ini
thanx for you help
|
|
|
|
|
I Want to convert from decimal number to binary number.
the decimal number is a fraction example .125;
Please help me
|
|
|
|
|
|
AFAIR, the binary rendering of a number is written the same way the decimal rendering is: with a decimal separator inbetween (I'll use the dot here).
So, I'd dare and say that 2.45 equals 10.101101
You'd think that, if you have no way to specify a binary representation of a float, you could still format the two parts and put them back together.
I am really just not sure if this is the correct way to represent a binary fraction...
|
|
|
|
|
I have this code ... I am getting an error when I declare a delegate Event
this.ChangeFilter += new System.EventHandler(this.ChangeFilter);
Error says Cannot assign to 'ChangeFilter' because it is 'Method Group'
private void ChangeFilter(object Source, System.EventArgs e)
{
// Response.Redirect("SelectSchema.aspx");
FilterByResolved(ddlResolvedFilter.SelectedItem.Value.ToString());
}
private void FilterByResolved(string strResolvedFilter)
{
strResolvedFilter = "ISCOMPLETE=" + strResolvedFilter;
try{
this.oracleDataAdapter1.Fill(this.LogDataSet1);
DataView LogFilterView = new DataView();
LogFilterView = this.LogDataSet1.Tables[0].DefaultView;
LogFilterView.RowFilter = strResolvedFilter;
DataGrid1.DataSource = LogFilterView;
DataGrid1.DataBind();
}
catch (Exception ex)
{
Label2.Text = ex.Message;
}
}
Thanks
|
|
|
|
|
I have this code but some how when I click on Hyperlink to sort it doesn't sort. I am sure I have a bug I can't figure it out ... I will really appericiate if any one can see any errors ...
In .aspx file
|
|
|
|
|
Hello,
I have created a typed dataset using a schema,
I am trying to create an instance of this dataset and get the row count.
It always returns total count as 0, when I know for sure taht there are 3 records, what am I doing wrong.?
InstrumentSettings ds = new InstrumentSettings();
ds.ReadXml(@"C:\Instruments.xml");
int x = ds.Instument.Rows.Count;
MessageBox.Show (x.ToString())
Thanks,
|
|
|
|
|
I remember having the same problem a while back and none of the second parameters I tried passing to ReadXml worked. Oddly enough, using a plain DataSet object worked like a charm.
Hopefully someone here will shed some light.
Regards,
Alvaro
... since we've descended to name calling, I'm thinking you're about twenty pounds of troll droppings in a ten pound bag. - Vincent Reynolds
|
|
|
|
|
i want to create SPSS file (.sav) in c#.net. i try searching on net, but could not find anything. if anyone know how to create SPSS file in c#.net please let me know. rigth now i am creating SPSS file manually.
Thank you,
SA
|
|
|
|
|
I can't believe I actually miss pointers and DDX! We recently started to migrate from VS6 C++ to .NET C#.
I have a form #1 with a comboBox control which contains 3 comboBoxes. The form also has a button on it which when clicked brings up another form with an instance of the comboBox control.
What do I have to do to get the original comboBox #1 to update to the same item selected when the user changes comboBox #1 on form #2???
Thanx,
Tom
|
|
|
|