private string OpenDOCXFile(string path)
{
Application word = null;
Document doc = null;
try
{
word = new Application() { Visible = false };
//word.ScreenUpdating = false;
object file = path;
//object nullobject = System.Reflection.Missing.Value;
//doc = wordObject.Documents.Open(ref file, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject);
word.DisplayAlerts = WdAlertLevel.wdAlertsNone;
Documents documents = word.Documents;
doc = documents.Open(path, NoEncodingDialog: true);
doc.ActiveWindow.Selection.WholeStory();
doc.ActiveWindow.Selection.Copy();
return Clipboard.GetText(TextDataFormat.Rtf);
}
catch (Exception ex)
{
Log.Error(ex.Message, "Something went wrong");
return string.Empty;
}
finally
{
//word.ScreenUpdating = true;
if (doc != null)
doc.Close();
if (word != null)
word.Quit();
}
}
код выше вешает UI , не понимаю почему, ведь я его вызываю в
public class EncodingViewModel : BaseViewModel
public class BaseViewModel : INotifyPropertyChanged
то есть как понимаю не в основном потоке UI