473,386 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Can it be slow to write to a very big .txt file?

Hi,

I use a streamwriter object to write in a text files hundreds time per
seconds. When my file get very big, can this process is subject to slow
down my application?

Here is part of my code.
Private ioFileOUT As StreamWriter

'In my constructor
Dim FileOUTStream As New FileStream(strFileName, FileMode.Append, _
FileAccess.Write, FileShare.ReadWrite)
ioFileOUT = New StreamWriter(FileOUTStream)

'In a subroutine
ioFileOUT.WriteLine(strMes)

Thanks :)

Marty
Nov 21 '05 #1
4 2427
I have another question, should I send the writing process in the file
to another thread? Or leave it in the current thread?

Thanks

Marty


Marty wrote:
Hi,

I use a streamwriter object to write in a text files hundreds time per
seconds. When my file get very big, can this process is subject to slow
down my application?

Here is part of my code.
Private ioFileOUT As StreamWriter

'In my constructor
Dim FileOUTStream As New FileStream(strFileName, FileMode.Append, _
FileAccess.Write, FileShare.ReadWrite)
ioFileOUT = New StreamWriter(FileOUTStream)

'In a subroutine
ioFileOUT.WriteLine(strMes)

Thanks :)

Marty

Nov 21 '05 #2
Marty <xm******@hotmail.com> wrote in news:oIGwd.85$dv1.81@edtnps89:
I have another question, should I send the writing process in the file
to another thread? Or leave it in the current thread?


If it's a large file, you should move it to a separate thread.

If you're doing a lot of string concatenation, take a look at the
stringbuilder class - it's much faster.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 21 '05 #3
Hi Lucas,

I am just writing to the text file to make a backup of my incoming feed.
My file can esaly get up to 400MB. Should I send the process to write
to another thread?

To pass it to the other thread, should I place my string in a collection
(FIFO) that the other thread can pool and write the collection content
to the .txt file?

Thanks

Marty

Lucas Tam wrote:
Marty <xm******@hotmail.com> wrote in news:oIGwd.85$dv1.81@edtnps89:

I have another question, should I send the writing process in the file
to another thread? Or leave it in the current thread?

If it's a large file, you should move it to a separate thread.

If you're doing a lot of string concatenation, take a look at the
stringbuilder class - it's much faster.

Nov 21 '05 #4
Marty <xm******@hotmail.com> wrote in news:v7Hwd.98$dv1.45@edtnps89:
Hi Lucas,

I am just writing to the text file to make a backup of my incoming feed.
My file can esaly get up to 400MB. Should I send the process to write
to another thread?
If you're writing the file in one chunk (i.e. 400MB at once) you should
move it to a separate thread - this prevents the main GUI thread from being
locked up.

To pass it to the other thread, should I place my string in a collection
(FIFO) that the other thread can pool and write the collection content
to the .txt file?


Sure, you can use the queue object for FIFO. Or you can pass the entire
feed straight to the writing class. However, I like the idea of using a
queue : )
--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 21 '05 #5

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

Similar topics

0
by: Dan Foley | last post by:
This script runs fine, but I'd like to know why it's so slow.. Thanks for any help out there on how i can make it faster (it might take up to 5 min to write these 3 export files whith 15 records...
1
by: Jawahar Rajan | last post by:
All, I am using the ASP code below to save some data from a SQL Server database via ADO as an Excel spreadsheet strReportName = Request.QueryString("ReportName") If len(strReportName) > 0 then...
7
by: spike | last post by:
Im writing a program to search for a string in a binary file. And it works. The problem is: It is sooo slow! how can i make it faster? It takes 27 seconds just to search a 5 meg file. I guess it...
8
by: BlueBall | last post by:
I am writing some kind of network testing tool and I have wrote the following code in ASP.NET with C# int size= 10048576; // around 10 MB data string buffer = ""; for (int j=1; j<=1024;...
1
by: John Bailo | last post by:
I wrote a simple test program, console, that does one thing: log DateTime.Now to a trace file. I thought it would be lickety-split, but it's taking more than 10 minutes to write 1 million lines....
50
by: diffuser78 | last post by:
I have just started to learn python. Some said that its slow. Can somebody pin point the issue. Thans
4
by: Ray | last post by:
Does anyone out there have experience with using Db2 8.2 with a program called MISys (also known as ACCPAC). I am having some problems with the application running exteremly slow on workstations...
5
by: rony_16 | last post by:
Hi, I have a problem downloading a file . after i connect to the website and get the stream , i treing to write the file on the HD. public void SaveStreamToFile(string filePath, Stream stream) {...
2
by: gnomee2 | last post by:
Hello Everyone, I have a strange problem that I cannot seem to solve. I have two server running Windows 2003 MSSQL on one IIS on the other. Out of the blue I have slow queries that cause asp...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...

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.