How to

add file to recent documents

Published: 27. January 2009 | Updated: 26. September 2011
License: Microsoft Public License (MS-PL)
Categories: File system » Files, Windows » Win32
Tags: C# Win32 Windows
Was this snippet helpful for you? YESYES / NONO

Import namespace

using System.Runtime.InteropServices;

Win API

[DllImport("shell32.dll", CharSet = CharSet.Ansi)]
public static extern void SHAddToRecentDocs(ShellAddToRecentDocsFlags flag, string path);

public enum ShellAddToRecentDocsFlags
{
    Pidl = 0x001,
    Path = 0x002,
}

Use

// adds document to recent files
SHAddToRecentDocs(ShellAddToRecentDocsFlags.Path, @"C:\document.txt");
Send us feedback about this snippet »



Related Snippets: