I have this code:
// Writing a byte[] to temporary folder as a word file
File.WriteAllBytes(Path.Combine(Path.GetTempPath(), formLanguage.FileName), formLanguage.FormFile);
var app = new Microsoft.Office.Interop.Word.Application();
Document doc = app.Documents.Open(Path.Combine(Path.GetTempPath(), formLanguage.FileName));
// what my main goal is to count the pages
var pageCount = doc.ComputeStatistics(
Microsoft.Office.Interop.Word.WdStatistic.wdStatisticPages);
formLanguage.NumberOfPages = pageCount;
object saveOption = WdSaveOptions.wdDoNotSaveChanges;
object originalFormat = WdOriginalFormat.wdOriginalDocumentFormat;
object routeDocument = false;
// here is where the debugger just doesn't continue.
doc.Close(saveOption, originalFormat, routeDocument);
app.Quit();
When doc.Close
is called my C# desktop application, it is just stuck and takes forever. Does anyone know what my mistake is or is it even possible to close a word document like this?