【发布时间】:2018-06-26 21:01:47
【问题描述】:
我希望能够在我的刽子手游戏程序中访问 Microsoft word doc 中的单词。这样我就可以只在文档中添加单词而不是实际的代码。我在想也许有一些方法可以获取这些单词并将它们添加到列表中?我不太确定,但如果有人可以提供帮助,那就太好了。
谢谢
编辑:
我尝试过的包括
string[] lines = System.IO.File.ReadAllLines(@"YourPathwayHere");
我什至尝试过其他人的代码,例如
List<string> woorden = new List<string>();
System.IO.StreamReader file = new System.IO.StreamReader(@"YourPathHere");
int counter = 0;
while (!file.EndOfStream)
{
string woord = file.ReadLine();
for (int i = 0; i < woord.Length; i++)
counter++;
}
Console.WriteLine(counter);
file.Close();
Console.ReadKey();
但所做的只是给我随机密钥(例如;???????at?HWGuays??jahso???)
【问题讨论】:
-
使用 txt 文件(不是 Word)
标签: c# text-files read-write