c# - 记事本如何在最近打开的文件夹中创建快捷链接

标签 c# windows notepad process.start recent-file-list

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

打开文本文件
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/

相关文章:

c# - 修改添加到字典: reimplement IDictionary vs inheriting from Dictionary

c++ - 使用命名管道的客户端服务器聊天

android - 如何打开Android SD卡上保存的目录

c# - 如何获取记事本文件保存位置

c++ - 在 Windows 上的环回接口(interface)上使用 tcp/ip 的延迟方面可以预期什么?

matlab - 为什么 fprintf 在文本模式下的行为与在正常模式下正确设置的回车符不同?

c# - 更高效的数据库访问

c# - 包装 Unity C# Monobehaviour 是否高效?

c# - RestSharp 发布 ByteArray/Stream 数据

c++ - GetLogicalProcessorInformation 和 SetProcessAffinityMask 中亲和掩码中的位索引是否相同?