示例#1
0
 private void Init(Uri uri)
 {
     if (uri.Scheme == "file")
     {
         Init(ShellUtil.GetShellItemForPath(uri.LocalPath));
     }
     else if (uri.Scheme == "shell")
     {
         var path           = uri.GetComponents(UriComponents.Path, UriFormat.Unescaped);
         var knownFolder    = path;
         var restOfPath     = string.Empty;
         var separatorIndex = path.IndexOf('/');
         if (separatorIndex != -1)
         {
             knownFolder = path.Substring(0, separatorIndex);
             restOfPath  = path.Substring(separatorIndex + 1);
         }
         if (restOfPath != string.Empty)
         {
             Init(this[restOfPath.Replace('/', '\\')].iShellItem);
         }
         else
         {
             Init(ShellUtil.GetKnownFolderFromPath(knownFolder));
         }
     }
     else
     {
         throw new InvalidOperationException("Invalid scheme.");
     }
 }