如何在启动文件夹中创建后更改名称文件?

时间:2017-02-10 06:50:46

标签: c# startup

我使用Code将我的应用程序添加到启动中 如何在创建文件(文件名+“。url”)之后更改为(文件名+“。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
        {

0 个答案:

没有答案