• Earn real money by being active: Hello Guest, earn real money by simply being active on the forum — post quality content, get reactions, and help the community. Once you reach the minimum credit amount, you’ll be able to withdraw your balance directly. Learn how it works.

c#:How Change Name File After Create

Status
Not open for further replies.

reza1

Junior Member
User
Joined
Nov 27, 2014
Messages
45
Reputation
0
Reaction score
4
Points
8
Credits
0
‎10 Years of Service‎
90%
I With Below Code my application added to startup

how I can after Creation File (file1 + ".url") Change To (file2 + ".exe")?

My Code:

Code:
>class addstartup
   {
       
       static string filename = "file1";
       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();
               }
           }
 
Status
Not open for further replies.
Back
Top