How to open a file using [ Command Prompt + C#] on VS2022 (Visual Studio 2022) automatically?
This is my code:
using System.Diagnostics;
namespace Search
{
partial class Form1 : Form
{
public Form1()
{
try
{
using (Process myProcess = new Process())
{
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.FileName = "%Username%\\search.lnk";
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
}
>Solution :
I belive it is not opening the file. Change below line and try
myProcess.StartInfo.UseShellExecute = true;