2010-07-21 81 views
0
名爲test.txt

我的文本文件包含使用c#刪除文件中的特定文本?

期間入住/退房&合併相關問題的要素籤和配套問題期間通過固定類型管理器錯誤。

現在我想刪除使用c#的文本「支持問題」。

請有人讓我知道。

由於提前, Naveenkumar.T

+0

你到底在問什麼?如何打開文件?如何解析文件?如何處理數據?至少,我們需要看到所述文本文件的格式。這並不難,但確實需要更多信息。 – 2010-07-21 10:55:18

+0

我想他很清楚地描述了 - 他有一個文本文件,內容顯示在問題中,他想從中刪除兩個單詞..? – 2010-07-21 10:57:48

+0

@Kieren Johnstone:是的,它已被重新格式化,現在更加清晰。當我發表我的評論時,我幾乎不清楚。 – 2010-07-21 11:38:35

回答

2

如果該文件是相當小的,你可以這樣做:

using System.IO; // at the top of the file 

string file = "path.txt"; // change to the path 

// read the whole file into a string, make a replacement, then write all string to a file 
File.WriteAllText(file, File.ReadAllText(file).Replace("supporting issues ","")); 

希望有所幫助。

+0

哈哈很好,這讓我們讀了太多的問題。好的! – Codesleuth 2010-07-21 10:59:19

+0

「文件」在哪裏定義? – spender 2010-07-21 11:00:19

+0

謝謝你,約翰斯通 – naveenkumar 2010-07-21 11:03:28

相關問題