weired error with doc file to extract text from it with some method.

Hi All,

i am having a trouble with the below method

 if (GetDocText.Native.NativeMethods.StgIsStorageFile(this._Path) != 0)

the above method always sometimes returns either 1 or 0 zero.

in my case for the .doc file it sholud always return zero (0) so the above condition checking for if will get false and the next statement will work.

Below is definition of the StgIsStorageFile method

using System;
using System.Runtime.InteropServices;

namespace GetDocText.Native
{
    internal class NativeMethods
    {
        private NativeMethods() { }

        const string Ole32Dll = "ole32.dll";

        [DllImport(Ole32Dll, CharSet = CharSet.Unicode)]
        public static extern int StgOpenStorage(string pwcsName, IStorage pstgPriority, int grfMode, IntPtr snbExclude, int reserved, out IStorage ppstgOpen);

        [DllImport(Ole32Dll, CharSet = CharSet.Unicode)]
        public static extern int StgIsStorageFile(string pwcsName);
    }
}

as this is from the metadata file as i do no have actual source of the methods in this .

as this is for the operation on the document file processing that too .doc file,

please kindly elaborate me the possible cause of the method is not working properly.

if more information required please let me know.

July 28th, 2015 11:14am

Hello All,

in the above scenario for the method  [DllImport(Ole32Dll, CharSet = CharSet.Unicode)]
        public static extern int StgIsStorageFile(string pwcsName);

what does StgIsStorageFile do , can anybody tell me about this.

as per my understanding i am trying to narrow the issue.

this could be wrong as well but i do need to resolve this , please kindly help me for this.

Free Windows Admin Tool Kit Click here and download it now
July 29th, 2015 1:39am

HI All,

I have come to narrow down the issue. and find the correct solution for the above issue.

actually the .doc file originally was not like a word file but it was only plain text file , although the above code is running correctly. issue was with .doc file only.

the resolution is the file should be proper .doc file only and not plain text containing the extension as .doc!!

  • Marked as answer by EmpAnsar 20 hours 17 minutes ago
July 29th, 2015 7:30am

Hi,

Thanks for sharing! It will help others who suck with the problem!

Best Regards

Free Windows Admin Tool Kit Click here and download it now
July 30th, 2015 3:30am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics