Bloom.ResolveShortcut.Resolve C# (CSharp) Method

Resolve() public static method

public static Resolve ( string filename ) : string
filename string
return string
        public static string Resolve(string filename)
        {
            #if !__MonoCS__
            ShellLink link = new ShellLink();
            ((IPersistFile)link).Load(filename, STGM_READ);
            // TODO: if I can get hold of the hwnd call resolve first. This handles moved and renamed files.
            // ((IShellLinkW)link).Resolve(hwnd, 0)
            StringBuilder sb = new StringBuilder(MAX_PATH);
            WIN32_FIND_DATAW data = new WIN32_FIND_DATAW();
            ((IShellLinkW)link).GetPath(sb, sb.Capacity, out data, 0);
            return sb.ToString();
            #else
            if (!SIL.IO.RobustFile.Exists(filename))
                return string.Empty;

            return SIL.IO.RobustFile.ReadAllText(filename);
            #endif
        }

Usage Example

        public virtual IEnumerable <BookCollection> GetSourceCollections()
        {
            foreach (var root in RepositoryFolders)
            {
                if (!Directory.Exists(root))
                {
                    continue;
                }

                foreach (var dir in Directory.GetDirectories(root))
                {
                    if (dir == _editableCollectionDirectory || Path.GetFileName(dir).StartsWith("."))                     //skip thinks like .idea, .hg, etc.
                    {
                        continue;
                    }
                    yield return(_bookCollectionFactory(dir, BookCollection.CollectionType.SourceCollection));
                }

                //follow shortcuts
                foreach (var shortcut in Directory.GetFiles(root, "*.lnk", SearchOption.TopDirectoryOnly))
                {
                    var path = ResolveShortcut.Resolve(shortcut);
                    if (path != _editableCollectionDirectory && Directory.Exists(path))
                    {
                        yield return(_bookCollectionFactory(path, BookCollection.CollectionType.SourceCollection));
                    }
                }
            }
        }
All Usage Examples Of Bloom.ResolveShortcut::Resolve
ResolveShortcut