2011-06-02 199 views

回答

16

若要將文件保存爲文本,你可以這樣做:

System.IO.File.WriteAllText("C:\your_path\your_file", Your_contents); 

在字符串中尋找的東西:

var position = Your_string.IndexOf("Book"); 

如果位置等於-1,那麼你正在尋找不存在。

6
File.WriteAllText("MyFile.txt", myString); // Write all string to file 
var wordBookIndex = myString.IndexOf("book"); // If the string is found, index != -1 
6

在你在哪裏可以找到這個信息實際上難倒關的機會,它是那樣簡單:

System.IO.File.WriteAllText(myPathToTheFile, myStringToWrite); 

要在另一個字符串中找到一個字符串,你只會做:

myString.Contains(someOtherString); // boolean 
myString.IndexOf(someOtherString); // find the 0 based index of the target string 
0

答案1問題

化妝用System.IO命名空間的有沒有類速效到WIRTE在文件中的文本

答案2問題

可以使用正則表達式或利用IndexOf函數用於搜索字符串中的特定字詞

相關問題