Hi,
I have used stream reader to read text file using Readline method, and i tried to append all string to string builder, but i'm not able to get all string value, i'm only getting last line of file, i have used the following coding
StreamReader reader = new StreamReader(@" d:\web_extract. txt",Encoding.D efault);
StringBuilder strbuild = null;
StreamWriter writer = null;
while(reader.Pe ek() >= 0)
{
string str = null;
str = reader.ReadLine ().ToString();
str = str.Replace("Ú" ," ");
strbuild = new StringBuilder() ;
// str = strbuild.Replac e("Ú"," ").ToString ();
strbuild.Append (str);
}
string str1 = strbuild.ToStri ng();
reader.Close();
writer = new StreamWriter(@" d:\web_extract1 .txt",true);
writer.Write(st r1);
writer.Close();
Please anybody help to solve this problem, advanced thanks for any reply.
Thanks.
2 1656
Hi,
I think you have to put the following line outside the while loop.
strbuild = new StringBuilder() ;
Regards
Mohith
Hi,
I have used stream reader to read text file using Readline method, and i tried to append all string to string builder, but i'm not able to get all string value, i'm only getting last line of file, i have used the following coding
StreamReader reader = new StreamReader(@" d:\web_extract. txt",Encoding.D efault);
StringBuilder strbuild = null;
StreamWriter writer = null;
while(reader.Pe ek() >= 0)
{
string str = null;
str = reader.ReadLine ().ToString();
str = str.Replace("Ú" ," ");
strbuild = new StringBuilder() ;
// str = strbuild.Replac e("Ú"," ").ToString ();
strbuild.Append (str);
}
string str1 = strbuild.ToStri ng();
reader.Close();
writer = new StreamWriter(@" d:\web_extract1 .txt",true);
writer.Write(st r1);
writer.Close();
Please anybody help to solve this problem, advanced thanks for any reply.
Thanks.
For every line your string is being reset to null except the last line where it exits the loop. HTH.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: cody |
last post by:
Why isn't there an StringBuilder.Append() overload with a StringBuilder as
argument?
Is there a reason that I missed?
|
by: PMB |
last post by:
Thank you in advance for any and all assistance.
I'm trying to use a make table query to pull the last transactionID, so I
can use an append query to reset the transactionID to the next sequential
number. My problem is, the make table query is taking all the
TransactionID's and putting them in the new table.
Is there a way to take the last transactionID only and put it in the new
table? So this way, when I clear the old Transactions,...
|
by: Marcio Kleemann |
last post by:
I need to force the first letter of each word in a line of text to
uppercase. The text comes from a TextBox control in a Web Form. I'm new to
..NET and am having a problem.
Since I can't modify the string directly, I convert the string to a char
using .ToCharArray() and set the first letter of each word to uppercase. The
problem then is I can't figure out how to convert the char array back to a
string. Whether I use .ToString() from the...
|
by: Two Beards |
last post by:
Hi, I'm new to VB and .net so I may be mising something. I am trying to
dynamically build some SQL by appending to a string. Part of the SQL
comes from an mp3 id tag I have extracted from a file and stored in a
string. I can do all the normal stuff with the string like msgbox and I
can append it to another string but I cannot append to the end of it.
I have tried things like trim and using a string builder but it still
won't work.
Any...
|
by: sklett |
last post by:
I need to take a string, make the first character lowercase and prepend an
underscore character to it. Something like this:
"California"
"_california"
Here is the (ugly) solution I cam up with:
public static string MakeNetSuiteStateName(string normalStateName)
{
string firstChar = normalStateName.Substring(0, 1);
| |
by: Mosquito Man |
last post by:
string s("0101");
I can't change it into s=1101
by
s='1';
because string.this is read-only, no assignment is allowed :-(
thank you for your help
|
by: TazaTek |
last post by:
Hello,
I've seen some vague references on how to do this a factory, but not
in enough detail to create one, or even know if it's what I need.
Essentially, I'll have one of about 5 classes that could be referenced
as a string (from a file).
I'm not 100% sure of the relationship between the classes, but I
suspect that they will not be derived from a base class, but in this
|
by: Lonifasiko |
last post by:
Hi,
Just want to replace character at index 1 of a string with another
character. Just want to replace character at that position. I thought
Replace method would be overloaded with an index parameter with which
you can write wanted character at that position. But no, Replace
method only allows replacing one known character with another. The
problem is I don't know the character to replace, just must replace
the character at a known...
|
by: wade.wall |
last post by:
Hi all,
I am having a problem appending data to an existing table. I have two
tables with identical fields and I want to append the data from one
table (T2) to the first (T1). T1 has 136 records and T2 has 209, for
a difference of 73 records. When I run the append query, only 72
records are selected from T2, and there doesn't seem to be a pattern
as to why the records selected were selected. They aren't the last 72
records or the...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |