我正在使用 c# 互操作 Word 进行开发,我需要知道页面何时结束,因为我正在创建一个 Word Table。行号并不总是相同的,如果页面没有结束,那么我必须插入一个中断页。
我该怎么做?
如果您使用 Streamreader
来读取 word 文件,则可以执行以下操作:
string path = @"C:..."; // the path of your word file
Streamreader sr = new Streamreader(path);
while (!sr.EndOfStream) {
// what you want to do
{
sr.Close();
如果你想知道你的文件在哪一行结束,你只需创建一个count
值,当你的文件结束时,你检查count
的值,你就有了它:
string path = @"C:..."; // the path of your word file
int count = 0;
Streamreader sr = new Streamreader(path);
while (!sr.EndOfStream) {
// what you want to do
count++;
{
sr.Close();