/// <summary>
        ///   Recurses project item searching for a version file with a given
        ///   name pattern.
        /// </summary>
        /// <param name="projectItem">
        ///   <c>ProjectItem</c> to recurse.
        /// </param>
        /// <param name="path">
        ///   Path to start search from.
        /// </param>
        /// <param name="filenamePattern">
        ///   Name of the file to search for. May contain wildcard characters.
        /// </param>
        /// <returns>
        ///   Array of full filenames (including path) if version file has been
        ///   found, otherwise, empty array.
        /// </returns>
        private string[] RecurseProjectForVersionInfoFile(ProjectItem projectItem, string path, string filenamePattern)
        {
            ArrayList versionFiles = new ArrayList();

            if (projectItem.Object != null)
            {
                string pathFileName = AppendBranchToPath(path, projectItem.Name);
                if (FileUtil.FilenameMatchesPattern(projectItem.Name, filenamePattern))
                {
                    string filename = ProjectItemInfo.GetItemFullPath(projectItem);
                    // it is not RC file (i.e. it is AssemblyInfo file),
                    // then it is the only version file so we can return
                    if (!filenamePattern.Equals("*.rc"))
                    {
                        return new string[] { filename }
                    }
                    ;
                    // there could be more .rc files, so check if this one contains version info
                    ResourceFileStream rfs = new ResourceFileStream(filename);
                    if (!rfs.GetVersions().Equals(AssemblyVersions.Empty))
                    {
                        versionFiles.Add(filename);
                    }
                }
                if (projectItem.ProjectItems != null)
                {
                    foreach (ProjectItem projectSubItem in projectItem.ProjectItems)
                    {
                        versionFiles.AddRange(RecurseProjectForVersionInfoFile(projectSubItem, pathFileName, filenamePattern));
                    }
                }
            }
            return((string[])versionFiles.ToArray(typeof(string)));
        }
 /// <summary>
 ///   Recurses project tree in Solution explorer, searching for the
 ///   item for which path is provided. When found, item is selected.
 /// </summary>
 /// <param name="projectInfo">
 ///   <c>ProjectInfo</c> of the project for which AssemblyInfo file has
 ///   to be selected.
 /// </param>
 /// <param name="parentNode">
 ///   Parent node in the Solution Explorer from which search is
 ///   started.
 /// </param>
 /// <param name="filename2select">
 ///   Full name of the file to select.
 /// </param>
 /// <returns>
 ///   Returns <c>true</c> if file has been found and selected; used to
 ///   break recursion if file has been found.
 /// </returns>
 private UIHierarchyItem RecurseProjectTree(UIHierarchyItem parentNode, string filename2select)
 {
     Debug.Assert(parentNode != null);
     foreach (UIHierarchyItem child in parentNode.UIHierarchyItems)
     {
         ProjectItem projectItem = child.Object as ProjectItem;
         if (projectItem != null)
         {
             string fullPath = ProjectItemInfo.GetItemFullPath(projectItem);
             if (string.Compare(fullPath, filename2select, true) == 0)
             {
                 SelectUIHierarchyItem(child);
                 return(child);
             }
             UIHierarchyItem item = RecurseProjectTree(child, filename2select);
             if (item != null)
             {
                 return(item);
             }
         }
     }
     return(null);
 }
        /// <summary>
        ///   Checks if a project item has been modified after the reference
        ///   date&time.
        /// </summary>
        /// <param name="projectItem">
        ///   <c>ProjectItem</c> for which check is done.
        /// </param>
        /// <param name="path">
        ///   Path to the project root.
        /// </param>
        /// <param name="dateTimeToCompare">
        ///   Reference date & time.
        /// </param>
        /// <param name="referenceFile">
        ///   Reference file to which comparison is done.
        /// </param>
        /// <returns>
        ///   <c>true</c> if the item has been modified after or at the
        ///   same time as the reference date & time.
        /// </returns>
        private bool IsProjectItemNewer(ProjectItem projectItem, DateTime dateTimeToCompare, string referenceFile)
        {
            string pathFileName = ProjectItemInfo.GetItemFullPath(projectItem);

            if (pathFileName != null && !FileUtil.IsDirectory(pathFileName) && !FileUtil.PathsAreEqual(pathFileName, referenceFile))
            {
                int comp = dateTimeToCompare.CompareTo((object)FileUtil.GetLastWriteTime(pathFileName));
                if (comp <= 0)
                {
                    return(true);
                }
            }
            if (projectItem != null && projectItem.ProjectItems != null)
            {
                foreach (ProjectItem projectSubItem in projectItem.ProjectItems)
                {
                    if (IsProjectItemNewer(projectSubItem, dateTimeToCompare, referenceFile))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }