PDA

View Full Version : تبدیل doc به xml



neilabak
جمعه 24 دی 1389, 13:41 عصر
سلام
من تو برنامم نیاز دارم یه فایل word رو که آپلود کردم به فرمت xml تو دیتابیس ذخیره کنم .
این کارو برای این نیاز دارم که وقتی میخوام این فایل ورد رو به کاربر نشون بدم فقط 10 صفحه اولشو نشونش بدم نه تمام فایل رو .ولی هر چی سرچ زدم چیز درست و درمونی که ایراد نداشته باشه پیدا نکردم.
من کد زیر رو نوشتم:



private static string SaveFullTextXml(string TezFile)
{
object ReadOnly = false;
Word.Application wordapp = new Word.Application();
wordapp.ScreenUpdating = false;
object xmlFormat = Word.WdSaveFormat.wdFormatXML;
object readOnly = false;
object f = TezFile;
object Visible = false;
object missing = System.Reflection.Missing.Value;
wordapp.Documents.Open(
ref f,
ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing,
ref missing);
Word.Document doc = wordapp.ActiveDocument;

doc.SaveAs2(ref f, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref xmlFormat, ref Visible, ref missing, ref missing, ref missing, ref missing);


return "";

}




ولی موقع رسیدن به خط زیر:



doc.SaveAs2(ref f, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref xmlFormat, ref Visible, ref missing, ref missing, ref missing, ref missing);


خطای زیر رو میده:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.