当我们使用记事本打开文本文件时,会在最近的文件夹中创建一个快捷方式文件。记事本如何在内部做到这一点。我尝试使用
打开文本文件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);
最佳答案
您可以尝试使用函数SHAddToRecentDocs
将文件添加到最近列表。
https://msdn.microsoft.com/en-us/library/windows/desktop/bb762105(v=vs.85).aspx
在这里您可以找到 C# 调用:
http://www.pinvoke.net/default.aspx/shell32.shaddtorecentdocs
关于c# - 记事本如何在最近打开的文件夹中创建快捷链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30116433/