Home > Back-end >  C # how to read the file specified, and the profession for editing, then save the file?
C # how to read the file specified, and the profession for editing, then save the file?

Time:04-13

C # how to read the file specified, and the profession for editing, then save the file?
Such as the following example: I want to read a file, read line by line, when detected a row exists "goose goose goose", on the next line added "sprinkle QuXiang song,"
But I have the following code, if no save, no effective, rookie here request passing by the great god grant instruction!

Private void button6_Click (object sender, EventArgs e)
{
NCTemp_Line=File. ReadAllLines (" D: \ \ is greatly large. TXT ");
for(int i=0; i{
If (NCTemp_Line [I] IndexOf (" goose goose goose ") & gt;=0)
{
NCTemp_Line [I]. Insert (0, "\ n" + "sprinkle QuXiang song" + "\ n");
}
}
}

CodePudding user response:

So-called modify delete file a certain position, is actually read the open files, a then 'a position before the modification and deletion of content + a + modification and deletion of the contents of the content of the modify delete position after b' save to file, and close the file. A, deleting a file, the file b changed its name to the same as the before file a name, that's it,
http://bbs.csdn.net/topics/391975224
  • Related