2011-06-02 202 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函数用于搜索字符串中的特定字词

相关问题