I've gone this far but it seems that it doesnt write in the file,can please someone tell me why!

public Form1()
        {
            InitializeComponent();
            aTimer = new System.Timers.Timer();
            aTimer.Elapsed += new System.Timers.ElapsedEventHandler(aTimer_Elapsed);
            aTimer.Interval = 30000;
            aTimer.Enabled = true;
            MessageBox.Show("Aveti 30 de secunde sa scrieti numele procesului");
        }

        System.Timers.Timer aTimer;
        StreamWriter writeTest;
        Process[] runningProcess;

        void aTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            runningProcess = Process.GetProcesses();
                foreach (Process proc in runningProcess)
                {
                    if (proc.StartInfo.FileName == txtBoxProcess.Text)
                    {
                        writeTest = new StreamWriter(@"C:\Users\P4\Desktop\test.txt");
                        string temp = Convert.ToString(proc.StartTime.DayOfYear);
                        writeTest.WriteLine(temp);
                        writeTest.Close();
                    }
                }
        }

        private void btnStart_Click(object sender, EventArgs e)
        {
            aTimer.Stop();

        }