Welcome to Dream.In.Code
Become a C# Expert!

Join 150,427 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,077 people online right now. Registration is fast and FREE... Join Now!




File related problem

 
Reply to this topicStart new topic

File related problem

cygnusX
28 Mar, 2008 - 08:39 AM
Post #1

D.I.C Head
**

Joined: 19 May, 2007
Posts: 159



Thanked: 2 times
My Contributions
I'm receiving file from POP3 server and obviosly if i want to open that file later or save it to the hard drive i have to add the incoming data to a string variable.

CODE

string file;
//every time i receive data from the server i iterate through it
foreach(string s in dataFromServer)
{
      file += blabla; //where 'blabla' is part of the received file,and of course this is done few thousand times,if not millions
}

The problem is that adding of strings to 'file' reduce the time for the receiving extremely.If i just receive the file without adding it to string it's about 25-30 seconds.The file that i'm receiving is 1300kb.25-30 seconds is ok,but i can't open(or save to disk) the file later.When i generate the file through adding the received data to 'file' the time for receiving is about 3 minutes or something like that.Is there a faster way to do what i want?How to generate the file faster(if it's possible)?

This post has been edited by cygnusX: 28 Mar, 2008 - 09:11 AM
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: File Related Problem
28 Mar, 2008 - 08:53 AM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,660



Thanked: 314 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
When you say download file are you talking about the encrypted attachment part of a pop3 email? Or are you talking about actually saving the email itself to a file on the system?
User is offlineProfile CardPM
+Quote Post

cygnusX
RE: File Related Problem
28 Mar, 2008 - 09:02 AM
Post #3

D.I.C Head
**

Joined: 19 May, 2007
Posts: 159



Thanked: 2 times
My Contributions
I know how to save it to the file system.My question was about generating the file,i.e. whether it can be done faster.Yes,it's encrypted attachment part of a POP3 mail.

Anyway,i found that i have to use StringBuilder instead of string.

This post has been edited by cygnusX: 28 Mar, 2008 - 09:24 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 08:42PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month