Esempio n. 1
0
        private void Button4_Click(object sender, EventArgs e)
        {
            f.comboBoxOptions.Clear();


            try
            {
                if (f.networkActual)
                {
                    ImpersonationHelper.Impersonate(f.targetDirectory, f.networkLogin, f.networkPassword, delegate
                    {
                        FileStream file = new FileStream(f.classesDirectory,
                                                         FileMode.Open, FileAccess.Read);

                        StreamReader strumien = new StreamReader(file);

                        while (!strumien.EndOfStream)
                        {
                            string temp = strumien.ReadLine();
                            f.comboBoxOptions.Add(temp);
                        }

                        strumien.Close();
                    });
                }
                else
                {
                    FileStream file = new FileStream(f.classesDirectory,
                                                     FileMode.Open, FileAccess.Read);

                    StreamReader strumien = new StreamReader(file);

                    while (!strumien.EndOfStream)
                    {
                        string temp = strumien.ReadLine();
                        f.comboBoxOptions.Add(temp);
                    }
                    strumien.Close();
                }

                f.comboBoxOptions.Sort();

                f.Save();

                System.Diagnostics.Process.Start("Success.exe");
            }
            catch (Exception)
            {
                System.Diagnostics.Process.Start("Error.exe");
            }
        }
Esempio n. 2
0
        private void Button1_Click(object sender, EventArgs e)
        {
            if (comboBox1.SelectedItem == null)
            {
                System.Diagnostics.Process.Start("errorr.exe");
                return;
            }

            string date = DateTime.Now.ToString();
            string trueDate = "";

            var macAddr =
             (
                 from nic in NetworkInterface.GetAllNetworkInterfaces()
                 where nic.OperationalStatus == OperationalStatus.Up
                 select nic.GetPhysicalAddress().ToString()
             ).FirstOrDefault();

            for (int i = 0; i < date.Length; i++)
                if (date[i] == ':')
                    trueDate += "-";
                else
                    trueDate += date.Substring(i,1);
            try
            {
                FileStream file = new FileStream("temporary.txt",
                FileMode.Create, FileAccess.Write);

                StreamWriter bytes = new StreamWriter(file);

                bytes.WriteLine(date);
                bytes.WriteLine(macAddr);
                bytes.WriteLine(comboBox1.SelectedItem);
                bytes.WriteLine(textBox1.Text);

                bytes.Close();

                if(networkActual)
                {
                    ImpersonationHelper.Impersonate(targetDirectory, networkLogin, networkPassword, delegate
                    {
                        if (!File.Exists(targetDirectory + trueDate + "_" + macAddr + ".txt"))
                        {
                            File.Copy("temporary.txt", targetDirectory + trueDate + "_" + macAddr + ".txt");
                        }
                    });
                }
                else
                {
                    if (!File.Exists(targetDirectory + trueDate + "_" + macAddr + ".txt"))
                    {
                        File.Copy("temporary.txt", targetDirectory + trueDate + "_" + macAddr + ".txt");
                    }
                }









                //var credentials = new NetworkCredential("rejestracja", "rej_1234");

                //using (new NetworkConnection(@"\\K3901\write", credentials))
                //{
                //    System.Diagnostics.Process.Start("SuccesSs.exe");
                //    //File.Copy(@"lol.txt", targetDirectory + "write\\" + "lol.txt");
                //}

                System.Diagnostics.Process.Start("SuccesSs.exe");
            }
            catch (Exception)
            {
                System.Diagnostics.Process.Start("Error.exe");
            }
        }