/// <summary>
        /// Creates a ShellObject given a parsing name
        /// </summary>
        /// <param name="parsingName"></param>
        /// <returns>A newly constructed ShellObject object</returns>
        internal static ShellObject Create(string parsingName)
        {
            if (string.IsNullOrEmpty(parsingName))
            {
                throw new ArgumentNullException("parsingName");
            }

            // Create a native shellitem from our path
            IShellItem2 nativeShellItem;
            Guid        guid    = new Guid("7E9FB0D3-919F-4307-AB2E-9B1860310C93");
            int         retCode = ShellNativeMethods.SHCreateItemFromParsingName(parsingName, IntPtr.Zero, ref guid, out nativeShellItem);

            if (retCode != 0)
            {
                throw new Exception("ShellObjectFactoryUnableToCreateItem", Marshal.GetExceptionForHR(retCode));
            }
            return(ShellObjectFactory.Create(nativeShellItem));
        }
Esempio n. 2
0
 /// <summary>
 ///     Creates a ShellObject subclass given a parsing name.
 ///     For file system items, this method will only accept absolute paths.
 /// </summary>
 /// <param name="parsingName">The parsing name of the object.</param>
 /// <returns>A newly constructed ShellObject object.</returns>
 public static ShellObject FromParsingName(string parsingName)
 {
     return(ShellObjectFactory.Create(parsingName));
 }
Esempio n. 3
0
 /// <summary>
 ///     Creates a new <c>ShellPropertyCollection</c> object with the specified file or folder path.
 /// </summary>
 /// <param name="path">The path to the file or folder.</param>
 public ShellPropertyCollection(string path) : this(ShellObjectFactory.Create(path))
 {
 }