Dispose() 공개 메소드

public Dispose ( ) : void
리턴 void
예제 #1
0
        public IEnumerator <IListItemEx> GetEnumerator()
        {
            var folder = this.GetIShellFolder();

            if (folder == null)
            {
                yield return(null);
            }

            HResult navRes;
            var     flags  = SHCONTF.FOLDERS | SHCONTF.INCLUDEHIDDEN | SHCONTF.INCLUDESUPERHIDDEN | SHCONTF.FASTITEMS | SHCONTF.NONFOLDERS | SHCONTF.ENABLE_ASYNC | SHCONTF.INIT_ON_FIRST_NEXT;
            var     enumId = ShellItem.GetIEnumIDList(folder, flags, out navRes);

            this.NavigationStatus = navRes;
            uint   count;
            IntPtr pidl;

            if (enumId == null)
            {
                yield break;
            }

            var result = enumId.Next(1, out pidl, out count);
            var i      = 0;

            while (result == HResult.S_OK)
            {
                var fsi = new FileSystemListItem();
                try {
                    fsi.InitializeWithParent(this.PIDL, this.ParentHandle, pidl, i++);
                } catch {
                    continue;
                }

                fsi.IsParentSearchFolder = this.IsSearchFolder;
                fsi.Dispose();
                yield return(fsi);

                result = enumId.Next(1, out pidl, out count);
            }

            if (folder != null)
            {
                Marshal.ReleaseComObject(folder);
            }

            if (result != HResult.S_FALSE)
            {
                //Marshal.ThrowExceptionForHR((int)result);
            }
            yield break;
        }
예제 #2
0
        public IEnumerable <IListItemEx> GetContents(Boolean isEnumHidden)
        {
            var folder = this.GetIShellFolder();

            if (folder == null)
            {
                yield return(null);
            }

            HResult navRes;
            var     flags = SHCONTF.FOLDERS | SHCONTF.NONFOLDERS | SHCONTF.CHECKING_FOR_CHILDREN | SHCONTF.ENABLE_ASYNC;

            if (isEnumHidden)
            {
                flags = SHCONTF.FOLDERS | SHCONTF.INCLUDEHIDDEN | SHCONTF.INCLUDESUPERHIDDEN | SHCONTF.NONFOLDERS | SHCONTF.CHECKING_FOR_CHILDREN | SHCONTF.ENABLE_ASYNC;
            }

            var enumId = ShellItem.GetIEnumIDList(folder, flags, out navRes);

            this.NavigationStatus = navRes;
            uint   count;
            IntPtr pidl;

            if (enumId == null)
            {
                yield break;
            }

            var result = enumId.Next(1, out pidl, out count);
            var i      = 0;

            while (result == HResult.S_OK)
            {
                //var sb = new StringBuilder(512);
                //Shell32.SHGetPathFromIDList(pidl, sb);
                //var ext = Path.GetExtension(sb.ToString());
                var fsi = new FileSystemListItem();
                try {
                    fsi.InitializeWithParent(this.PIDL, this.ParentHandle, pidl, i++);
                } catch {
                    continue;
                }
                fsi.IsParentSearchFolder = this.IsSearchFolder;
                fsi.Dispose();
                yield return(fsi);

                //Shell32.ILFree(pidl);
                result = enumId.Next(1, out pidl, out count);
            }

            if (folder != null)
            {
                Marshal.ReleaseComObject(folder);
            }

            if (result != HResult.S_FALSE)
            {
                //Marshal.ThrowExceptionForHR((int)result);
            }

            //parentItem.Dispose();
            yield break;
        }