none
Repair/Cancel File Indetification RRS feed

  • Question

  • I am using C#.net application,

    Is there any way we can directly identify, if office files(PowerPoint/Word) require to Repair...

    how do we Repair same files using C# application.

    is there any specific Error code return by COMException for file require repair?

    Any resolution please share the same.

    Note: I need a list of Files that requires Repair from listed files directory.

    Wednesday, August 17, 2016 12:52 PM

All replies

  • Hello,

    There is no trivial way for detecting whether Office files should be repaired.

    What code did you try for opening such files? Do you get any exceptions in the code?


    [custom.development]

    Wednesday, August 17, 2016 3:39 PM
  • I am using below code,

    try
                {
                    Microsoft.Office.Interop.PowerPoint.Application poweApp = new Microsoft.Office.Interop.PowerPoint.Application();
                    //poweApp.Presentations.CheckOut(textBox1.Text);
                    FileInfo fileInfo = new FileInfo(textBox1.Text);
                    poweApp.Presentations.Open(fileInfo.FullName, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoTrue, WithWindow: Microsoft.Office.Core.MsoTriState.msoFalse);
                    Console.Write(poweApp.Presentations.Count);
                }
                catch (System.Runtime.InteropServices.COMException comException)
                {
                    Console.WriteLine(comException.Message);
                    //throw;
                }


    ComException Detail are as below:

    comException.Message:
    "Presentations (unknown member) : Office has detected a problem with this file. To help protect your computer this file cannot be opened."
    comException.ErrorCode:
    -2147188158




    • Edited by Viral84 Tuesday, August 30, 2016 10:27 AM
    Tuesday, August 30, 2016 9:14 AM
  • >>"Presentations (unknown member) : Office has detected a problem with this file. To help protect your computer this file cannot be opened."

    To open the file which need to be repaired, you could use Presentations.Open2007 Method (PowerPoint),there is a parameter: OpenAndRepair

    Type: System.Object

    Optional Object. True to repair the document to prevent document corruption.

     

    >>I need a list of Files that requires Repair from listed files directory

    If you want to list the files need to be repair, as what Eugene said, we are unable to do that by using object model.

    Tuesday, August 30, 2016 11:45 AM
    Moderator