get comments in .xlsm files properties in c#

177 views Asked by At

Is there any way to get comments from .xlsm files using Shell32.dll?

This is code I am using

    public string getFileCommentsProperty(string FileName)
    {

            string file_version="";

            Shell32.Shell shell = new Shell32.Shell();

            Shell32.Folder objFolder;

            objFolder = shell.NameSpace(System.IO.Path.GetDirectoryName(FileName));



            foreach (Shell32.FolderItem2 item in objFolder.Items())
            {

                if (System.IO.Path.GetFileNameWithoutExtension(FileName).ToString() == System.IO.Path.GetFileNameWithoutExtension(objFolder.GetDetailsOf(item, 0).ToString()))
                { 


                    file_version = objFolder.GetDetailsOf(item, 24).ToString();
                    break;
                }
            }

            return file_version;                    
        }

This code works if I create a standalone console application but if use this in a web application it just returns blank.I used the Microsoft Shell and Automation reference from the com components Tab.Has anyone come across this issue?

0

There are 0 answers