C# 在启动文件夹中创建后如何更改文件名?
我将我的应用程序代码添加到启动中 如何在创建文件(filename+“.url”)后更改为(filename+“.exe”)C# 在启动文件夹中创建后如何更改文件名?,c#,startup,C#,Startup,我将我的应用程序代码添加到启动中 如何在创建文件(filename+“.url”)后更改为(filename+“.exe”) 再解释一点,你的问题我不清楚。你为什么不用“.exe”创建它?我用StreamWriter(deskDir+“\\”+filename+“.url”)在启动时生成文件,5秒钟后生成文件,将文件名更改为filename+“.exe” static string filename = "troj"; public static string tempure = Env
再解释一点,你的问题我不清楚。你为什么不用“.exe”创建它?我用StreamWriter(deskDir+“\\”+filename+“.url”)在启动时生成文件,5秒钟后生成文件,将文件名更改为filename+“.exe”
static string filename = "troj";
public static string tempure = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\" + filename + ".exe";
public static string tempurepath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\";
public static void addtostart()
{
try
{
string deskDir = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
if (System.IO.File.Exists(deskDir + "\\" + filename + ".url")) return;
using (System.IO.StreamWriter writer = new System.IO.StreamWriter(deskDir + "\\" + filename + ".url"))
{
string app = tempure;
writer.WriteLine("[InternetShortcut]");
writer.WriteLine("URL=file:///" + app);
writer.WriteLine("IconIndex=0");
string icon = app.Replace('\\', '/');
writer.WriteLine("IconFile=" + icon);
writer.Flush();
}
}
catch
{