protected override void OnDisposeManaged() { if (File != null) { File.Dispose(); File = null; } base.OnDisposeManaged(); }
/// <summary> /// Load the library using a number of options /// </summary> /// <param name="libraryName">The name of the library.</param> /// <param name="folderPath">The path to the library.</param> /// <param name="isReadOnly">If <B>true</B>, opens the library in read-only mode.</param> /// <returns>A ShellLibrary Object</returns> public static ShellLibrary Load(string libraryName, string folderPath, bool isReadOnly) { CoreHelpers.ThrowIfNotWin7(); // Create the shell item path string shellItemPath = System.IO.Path.Combine(folderPath, libraryName + FileExtension); ShellFile item = ShellFile.FromFilePath(shellItemPath); IShellItem nativeShellItem = item.NativeShellItem; INativeShellLibrary nativeShellLibrary = (INativeShellLibrary) new ShellLibraryCoClass(); AccessModes flags = isReadOnly ? AccessModes.Read : AccessModes.ReadWrite; nativeShellLibrary.LoadLibraryFromItem(nativeShellItem, flags); ShellLibrary library = new ShellLibrary(nativeShellLibrary); try { library.nativeShellItem = (IShellItem2)nativeShellItem; library.Name = libraryName; return(library); } catch { library.Dispose(); throw; } }
internal static void FillCommonData(ShellFile shell, MetaData data) { if (shell.IsFileSystemObject) { data.Add(new MetaEntry { Name = FileMetaData.ModifiedDate.Name, Value = shell.Properties.GetProperty(SystemProperties.System.DateModified).ValueAsObject }); data.Add(new MetaEntry { Name = FileMetaData.Type.Name, Value = shell.Properties.GetProperty(SystemProperties.System.ItemTypeText).ValueAsObject }); data.Add(new MetaEntry { Name = FileMetaData.Size.Name, Value = shell.Properties.GetProperty(SystemProperties.System.Size).ValueAsObject }); } }
private VideoInfo(ShellFile shellFile) { this.FrameRate = MeasurePlayer.FrameRate.Create(shellFile.Properties.System.Video.FrameRate.Value); this.Duration = CreateDuration(shellFile.Properties.System.Media.Duration.Value); }
/// <summary> /// Creates a ShellFileSystemObject given a native IShellItem interface /// </summary> /// <param name="nativeShellItem"></param> /// <returns>A newly constructed ShellFileSystemObject object</returns> internal static new ShellFileSystemObject FromShellItem(IShellItem nativeShellItem) { string path = null; // Get the full system path from the native IShellItem path = ShellHelper.GetParsingName(nativeShellItem); if (string.IsNullOrEmpty(path)) throw new ArgumentException("Cannot create a ShellFileSystemObject from", "nativeShellItem"); ShellFileSystemObject item = null; if (File.Exists(path)) { item = new ShellFile(); } else if (Directory.Exists(path)) { item = new ShellFolder(); } else if (path.StartsWith("::")) // It's a special folder, we'll use it { //TODO: Construct a special type for registered non-folder Shell items item = new ShellFile(); } else { return null; // There aren't any other options left } item.Path = path; item.nativeShellItem = (IShellItem2)nativeShellItem; return item; }
public ShellFileVM(IItemProvider provider, ContainerVM parent, ShellFile file) : base(provider, parent, file.GetDisplayName(DisplayNameType.Default), false) { File = file; Util.FillCommonData(file, MetaData); }