1

当我们使用记事本打开文本文件时,会在最近的文件夹中创建一个快捷方式文件。记事本如何在内部进行。我尝试使用打开文本文件

Process.Start("C:\test.txt");

但是没有创建快捷方式。但对于其他文件,如图像、视频和音频,正在创建最近的文件快捷方式。通过使用

Process.start("c:\summer.jpeg");

我也尝试使用下面的命令。

ProcessStartInfo psi = new ProcessStartInfo();
psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.UseShellExecute = true;
psi.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.System);
psi.FileName = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "notepad.exe");
psi.Arguments = "C:\test.txt";

Process.Start(psi);
4

1 回答 1

2

您可以尝试使用该功能SHAddToRecentDocs将文件添加到最近列表中。

https://msdn.microsoft.com/en-us/library/windows/desktop/bb762105(v=vs.85).aspx

在这里你可以找到 C# 调用:

http://www.pinvoke.net/default.aspx/shell32.shaddtorecentdocs

于 2015-05-08T05:59:50.760 回答