Skip to content
| Marketplace
Sign in
Visual Studio>Templates>RuMRUManager
RuMRUManager

RuMRUManager

Klaus Ruttkowski

|
5,307 installs
| (0) | Free
Manage MRU menu and save it to an XML file.
Download

RuMRUManager

MRU.jpg

After installation, you can find the ItemTemplate here:

Ru2__1.jpg

Add Most Recently Used Files (MRU) List to Windows Applications from Adib Saad

https://www.codeproject.com/Articles/407513/Add-Most-Recently-Used-Files-MRU-List-to-Windows-A

Changed, stored not in the registry but in an XML file from Klaus Ruttkowski

1) Set the desired location of the MRU file in public class MRUManager

private MRUDataPath mruDataPath = MRUDataPath.Roaming; // MRUDataPath { Local, Roaming, Common, ExePath };

2) Create Class Form1

3) Insert Event Form1_Load

4) Insert ToolStrip with menu top Item "File" and sub items

a) "Open

b) "Recent

5) Insert the following code in the corresponding places.

using System.IO; using RuFramework.MRU;

namespace RuMRUManager { public partial class Form1 : Form { private MRUManager mruManager; public Form1() { InitializeComponent(); } ///

/// Init MRUManager /// /// /// private void Form1_Load(object sender, EventArgs e) { this.mruManager = new MRUManager(this.recentToolStripMenuItem, // Recent menu this.MRU_Open); // MRU Funtion open cliced. }

    private void openToolStripMenuItem_Click(object obj, EventArgs evt)
    {
        OpenFileDialog openFileDlg = new OpenFileDialog();
        openFileDlg.InitialDirectory = Environment.CurrentDirectory;
        if (openFileDlg.ShowDialog() != DialogResult.OK)
            return;
        string fileName = openFileDlg.FileName;

        //Now give it to the MRUManager
        this.mruManager.AddRecentFile(fileName);
        // Common function to open the file
        Open(fileName);
    }
    /// <summary>
    /// if Open from MRUList
    /// </summary>
    /// <param name="obj"></param>
    /// <param name="evt"></param>
    private void MRU_Open(object obj, EventArgs evt)
    {
        string fileName = (obj as ToolStripItem).Text;
        if (!File.Exists(fileName))
        {
            // Recent file not exist
            this.mruManager.RemoveRecentFile(fileName);
            MessageBox.Show(fileName + " not exist, Item deleded.");
            return;
        }
        // Common function to open the file
        Open(fileName);
    }
    /// <summary>
    /// Common function to open the file
    /// </summary>
    /// <param name="fileName">filename</param>
    private void Open(string fileName)
    {
        MessageBox.Show("Open: " + fileName);
        // TODO: Your file open
    }
  }

}

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft