By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,640 Members | 2,355 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,640 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.