/// <summary> /// Refresh the file / directory info. Does not refresh directory contents /// because it refresh every time GetFiles/Directories/FileSystemInfos is called. /// </summary> public void Refresh(RefreshModeEnum mode = RefreshModeEnum.AllProps) { RefreshMode |= mode; //0.23 : Delay loading some properties. PIDL relPIDL = null; if (!Exists) { refresh(null, null, null, mode); } else { try { //0.16: Fixed ShellFolder not freed this.RequestPIDL(pidlLookup => { using (ShellFolder2 sf = getParentIShellFolder(pidlLookup, out relPIDL)) refresh(sf, relPIDL, pidlLookup, mode); }); } catch (NullReferenceException) { refresh(null, null, null, mode); } }
protected void checkRefresh(RefreshModeEnum mode = RefreshModeEnum.AllProps) { if ((RefreshMode & mode) != mode) { Refresh(mode); } }
protected override void refresh(IShellFolder2 parentShellFolder, PIDL relPIDL, PIDL fullPIDL, RefreshModeEnum mode) { base.refresh(parentShellFolder, relPIDL, fullPIDL, mode); if ((mode & RefreshModeEnum.FullProps) != 0 && parentShellFolder != null && relPIDL != null && fullPIDL != null) { if (!FullName.StartsWith("::") && File.Exists(FullName)) { try { FileInfo fi = new FileInfo(FullName); IsReadOnly = fi.IsReadOnly; Attributes = fi.Attributes; Length = fi.Length; LastAccessTime = fi.LastAccessTime; LastWriteTime = fi.LastWriteTime; CreationTime = fi.CreationTime; } catch { } } else //0.18: Uses File to return FileInfo by default { ShellAPI.SFGAO attribute = shGetFileAttribute(fullPIDL, ShellAPI.SFGAO.READONLY); IsReadOnly = (attribute & ShellAPI.SFGAO.READONLY) != 0; Length = 0; } } }
protected virtual void refresh(IShellFolder2 parentShellFolder, PIDL relPIDL, PIDL fullPIDL, RefreshModeEnum mode) { if (parentShellFolder != null && fullPIDL != null && relPIDL != null) { Attributes = loadAttributes(parentShellFolder, fullPIDL, relPIDL); string parseName = loadName(parentShellFolder, relPIDL, ShellAPI.SHGNO.FORPARSING); FullName = ""; //Console.WriteLine("relPIDL.size = {0}", relPIDL.Size); //Console.WriteLine("PIDL.size = {0}", _pidl.Size); if (relPIDL.Size == 0) { FullName = IOTools.IID_Desktop; } else //0.12: Fixed Fullname of User/Shared directory under desktop is now it's GUID instead of it's file path. //0.13: Fixed All subdirectory under User/Shared directory uses GUID now. { if (DirectoryInfoEx.CurrentUserDirectory != null) { if (parseName == DirectoryInfoEx.CurrentUserDirectory.FullName && loadName(parentShellFolder, ShellAPI.SHGNO.FORPARSING) == Environment.GetFolderPath(Environment.SpecialFolder.Desktop)) { FullName = IOTools.IID_UserFiles; } //else if ( // (parseName.StartsWith(DirectoryInfoEx.CurrentUserDirectory.FullName) && // _parent != null && _parent.FullName.StartsWith(IOTools.IID_UserFiles)) // || // (OriginalPath != null && OriginalPath.StartsWith(IOTools.IID_UserFiles)) // ) //{ // FullName = parseName.Replace(DirectoryInfoEx.CurrentUserDirectory.FullName, IOTools.IID_UserFiles); //} } if (DirectoryInfoEx.SharedDirectory != null) { if (parseName == DirectoryInfoEx.SharedDirectory.FullName && loadName(parentShellFolder, ShellAPI.SHGNO.FORPARSING) == Environment.GetFolderPath(Environment.SpecialFolder.Desktop)) { FullName = IOTools.IID_Public; } //else if ( // (parseName.StartsWith(DirectoryInfoEx.SharedDirectory.FullName) && // _parent != null && _parent.FullName.StartsWith(IOTools.IID_Public)) // || // (OriginalPath != null && OriginalPath.StartsWith(IOTools.IID_Public)) // ) // FullName = parseName.Replace(DirectoryInfoEx.SharedDirectory.FullName, IOTools.IID_Public); } //if (_parent != null && _parent.FullName.StartsWith(IOTools.IID_Library) // && !parseName.StartsWith(IOTools.IID_Library)) // FullName = PathEx.Combine(_parent.FullName, PathEx.GetFileName(parseName)); if (FullName == "") { FullName = parseName; } } //if (DirectoryInfoEx.CurrentUserDirectory != null && parseName == DirectoryInfoEx.CurrentUserDirectory.FullName && //loadName(parentShellFolder, ShellAPI.SHGNO.FORPARSING) == Environment.GetFolderPath(Environment.SpecialFolder.Desktop)) // FullName = IOTools.IID_UserFiles; //else //if (DirectoryInfoEx.SharedDirectory != null && parseName == DirectoryInfoEx.SharedDirectory.FullName && // loadName(parentShellFolder, ShellAPI.SHGNO.FORPARSING) == Environment.GetFolderPath(Environment.SpecialFolder.Desktop)) // FullName = IOTools.IID_Public; //else if (OriginalPath == null) { OriginalPath = FullName; } if (parseName.StartsWith("::")) //Guid { parseName = loadName(parentShellFolder, relPIDL, ShellAPI.SHGNO.NORMAL); } _name = FullName.EndsWith("\\") ? FullName : PathEx.GetFileName(FullName); Label = loadName(parentShellFolder, relPIDL, ShellAPI.SHGNO.NORMAL); } else { if (OriginalPath != null) { string origPath = Helper.RemoveSlash(OriginalPath); _name = Path.GetFileName(origPath); Label = _name; FullName = origPath; } } }
protected override void refresh(IShellFolder2 parentShellFolder, PIDL relPIDL, PIDL fullPIDL, RefreshModeEnum mode) { base.refresh(parentShellFolder, relPIDL, fullPIDL, mode); if ((mode & RefreshModeEnum.FullProps) != 0 && parentShellFolder != null && relPIDL != null && fullPIDL != null) { ShellAPI.SFGAO attribute = shGetFileAttribute(fullPIDL, ShellAPI.SFGAO.BROWSABLE | ShellAPI.SFGAO.FILESYSTEM | ShellAPI.SFGAO.HASSUBFOLDER); IsBrowsable = (attribute & ShellAPI.SFGAO.BROWSABLE) != 0 || (attribute & ShellAPI.SFGAO.CONTENTSMASK) != 0; IsFileSystem = (attribute & ShellAPI.SFGAO.FILESYSTEM) != 0; HasSubFolder = (attribute & ShellAPI.SFGAO.HASSUBFOLDER) != 0; if (!FullName.StartsWith("::") && Directory.Exists(FullName)) { try { DirectoryInfo di = new DirectoryInfo(FullName); Attributes = di.Attributes; LastAccessTime = di.LastAccessTime; LastWriteTime = di.LastWriteTime; CreationTime = di.CreationTime; } catch { } } initDirectoryType(); } }