RuMRUManager
After installation, you can find the ItemTemplate here:
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 };
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
}
}
}