|
-
Sep 6th, 2004, 10:25 AM
#1
Thread Starter
PowerPoster
insert text ....
hi there
I have a text file, this text file may change, however it will have a % character in it.
this % character, will indicate that some filename / text goes in, so it replaces the %.
how can i do this in C#?
I have a text box, where the information goes, and wish to update that info regardless of what this "main" file is, but replaces the % with some other text.
any ideas?
[edit]so really, we need to know if there is some sort of INSTR (instring) function like VB which will look at the string and replace it with some text of your choice when it finds a particular string you wish to replace it with....[/edit]
Last edited by Techno; Sep 6th, 2004 at 10:38 AM.
-
Sep 6th, 2004, 11:08 AM
#2
Frenzied Member
Take a look at some of the String members - .IndexOf, .Substring, .Replace etc. - should give you what you need.
-
Sep 6th, 2004, 11:24 AM
#3
Thread Starter
PowerPoster
replace....string builder works thanks!
another thing is, how to i detect until its reached to the end of the file?
i am using readline (because i need to add some stuff so thats why im not using readtoend)
-
Sep 6th, 2004, 12:08 PM
#4
Frenzied Member
Assuming you're using StreamReader
Code:
using (StreamReader sr = new StreamReader("TestFile.txt"))
{
String line;
// Read and display lines from the file until the end of
// the file is reached.
while ((line = sr.ReadLine()) != null)
{
Console.WriteLine(line);
}
}
Something like that, which, BTW, was copied and pasted from MSDN. MSDN is a great resource, it's worth searching.
Mike
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|