none
I copied my application exe file to my second hard drive how do i use/run the exe file from the second drive now ?

    Question

  • I run the application its copying the exe file with another name to another location i want now that if i run the exe from the other location it will do another things and not the same things it did in the first time. Like in the project to make that the second exe file will use and do things from another code in the same project.

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;
    
    
    namespace test
    {
        public partial class Form1 : Form
        {
            string applicationFileName;
            string[] hardDrivedInfo;
    
            public Form1()
            {
                InitializeComponent();
    
                applicationFileName = Path.GetDirectoryName(Application.ExecutablePath + "\\test.exe");            
                hardDrivedInfo = System.IO.Directory.GetLogicalDrives();
                foreach (string str in hardDrivedInfo)
                {
                    if (str.Contains("D"))
                    {
                        File.Move(applicationFileName, str+"\\abcdefg.exe");
                        MessageBox.Show("Oops something went wrong sorry");
                    }
                }
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
    
            }
        }
    }
    
    So now in D: i have abcdefg.exe and i want it to make something else when i run it. How can i do it ?


    danieli

    Tuesday, May 29, 2012 3:25 PM

Answers

  • You could do it via command line args.  When you run the executable in the new location pass along some additional command line parameter, and then when the program is started, if you see that the command line parameter exists, do something different.
    • Marked as answer by chocolade Tuesday, May 29, 2012 5:10 PM
    Tuesday, May 29, 2012 3:43 PM