示例#1
0
        public Mru(string _Hostname, string _Path, string _Filename, Jrfc.Shell.ShortcutType _ShortcutType = Shell.ShortcutType.WindowsShortcut)
        {
            this.Hostname        = _Hostname;
            this.Path            = _Path;
            this.Filename        = _Filename;
            this.MruShortcutType = _ShortcutType;

            if (!string.IsNullOrWhiteSpace(this.Filename))
            {
                this.DisplayName = this.Filename;
            }
            else
            {
                this.DisplayName = this.Path;
            }
            if (this.MruShortcutType == Jrfc.Shell.ShortcutType.InternetShortcut)
            {
                this.DisplayName = this.DisplayName.Replace("%20", " ");
            }
        }
示例#2
0
        public void AddOfficeRecent(string _Hostname, string[] _FileExtensionList)
        {
            string path = @"\\" + _Hostname + @"\c$\Users\" + Jrfc.ActiveDirectory.GetWindowsUserName() + @"\AppData\Roaming\Microsoft\Office\Recent";

            DirectoryInfo di = new DirectoryInfo(path);

            FileInfo[] fi_list = di.GetFiles("*.*", SearchOption.TopDirectoryOnly);

            string mru_path;
            string mru_file;
            string mru_ext;

            foreach (FileInfo fi in fi_list)
            {
                if (fi.Name == "Templates")
                {
                    continue;
                }

                Jrfc.Shell.ShortcutType shortcut_type = Jrfc.Shell.GetShortcutType(fi.Name);

                if (shortcut_type == Jrfc.Shell.ShortcutType.WindowsShortcut)
                {
                    mru_path = Jrfc.Shell.GetWindowsShortcutTargetFilePath(fi.FullName);
                    if (string.IsNullOrWhiteSpace(mru_path))
                    {
                        continue;
                    }
                    if (_Hostname == "localhost")
                    {   // Do not include mru files from local drives. These files
                        // will not be visible to the RDS server.
                        DriveInfo drv = new DriveInfo(mru_path);
                        if (drv.DriveType != DriveType.Network)
                        {
                            continue;
                        }
                    }
                    mru_file = Path.GetFileName(fi.Name);
                    if (!string.IsNullOrWhiteSpace(mru_file))
                    {
                        continue;
                    }

                    mru_ext = Path.GetExtension(mru_path);
                }
                else if (shortcut_type == Jrfc.Shell.ShortcutType.InternetShortcut)
                {
                    string url = Jrfc.Shell.GetInternetShortcut(fi.FullName);
                    if (string.IsNullOrWhiteSpace(url))
                    {
                        continue;
                    }

                    Uri uri = new Uri(url);
                    mru_file = Path.GetFileName(uri.AbsolutePath);
                    if (string.IsNullOrWhiteSpace(mru_file))
                    {
                        continue;
                    }

                    mru_ext  = Path.GetExtension(mru_file);
                    mru_path = url;
                }
                else
                {
                    continue;
                }
                if (!string.IsNullOrWhiteSpace(mru_ext))
                {
                    mru_ext = mru_ext.Trim('.').ToLower();
                    if (_FileExtensionList.Contains(mru_ext))
                    {
                        this.Add(new Mru(_Hostname, mru_path, mru_file, shortcut_type));
                    }
                }
            }
        }