How to add file to Recent Docunents in .NET?

50 views Asked by At

I'm trying to figure out how to add a file to the recent documents using .NET. In this post SHAddToRecentDocs doesn't add my file to recent documents it shows how to do it via C# but how do I do it with VB.NET? Is it possible?

1

There are 1 answers

0
JayJay101 On

Thank you for your help! Using https://converter.telerik.com/ I was able to figure it out.

This is what I used:

Public Enum ShellAddToRecentDocsFlags
    Pidl = &H1
    Path = &H2
    PathW = &H3
End Enum

<DllImport("Shell32.dll", BestFitMapping:=False, ThrowOnUnmappableChar:=True)>
Private Shared Sub SHAddToRecentDocs(ByVal flag As ShellAddToRecentDocsFlags,
<MarshalAs(UnmanagedType.LPStr)> ByVal path As String)