a C# Question :O





Hello , I dont know a good forum for c# so i ask it here ^^
I made a program and it almost works i have no errors but
if i start debugging and it comes here:

1
2
3
4
5
6
7
8
9
10
            {
                File.Create(@"c:\config.txt");
                Thread.Sleep(1000);
                StreamWriter Newfile = new StreamWriter(@"c:\config.txt");
                Newfile.WriteLine(DefaultURL);
                Newfile.WriteLine(DefaultTimes);
                Newfile.WriteLine(DefaultInterval);
                Newfile.Close();
                Main(args);
            }

it stops and says:
StreamWriter Newfile = new StreamWriter(@"c:\config.txt")
is already in use by an other process


Full Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading;
using System.IO;


namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Vieuw.Main2(); // Make's The Console Window Invisible 
            int Sleep = 1000;
            string SleepString;
            int Timer = 0;
            string Website = "";
            int Time = 0;
            string TimeString = Time.ToString();

            // If the config.txt Doesnt Exits it will make it with these defalut options
            // -------------------------------------------------------------------------
            string DefaultURL = ""; 
            string DefaultTimes = "";
            string DefaultInterval = "";
            // -------------------------------------------------------------------------


            if (File.Exists(@"c:\config.txt"))
            {

                StreamReader Stream = new StreamReader(@"c:\config.txt");
                Website = Stream.ReadLine();
                TimeString = Stream.ReadLine();
                SleepString = Stream.ReadLine();
                Stream.Close();
                Sleep = Convert.ToInt32(SleepString);
                Time = Convert.ToInt32(TimeString);
                Sleep = Sleep * 1000; // From MilliSeconds -> Seconds 
                // Console.WriteLine("Website: " + Website);
                // Console.WriteLine("Time's: " + TimeString);
                //Console.WriteLine("Interval in MS :" + Sleep);
                if (Website != "" && TimeString != "" && SleepString != "")
                {
                    while (Timer != Time)
                    {
                        Timer++;
                        Console.WriteLine(Time);
                        AddSpam(Website);
                        Thread.Sleep(Sleep);

                    }

                }
                else { Environment.Exit(0); }
            }
            else
            {
                File.Create(@"c:\config.txt");
                Thread.Sleep(1000);
                StreamWriter Newfile = new StreamWriter(@"c:\config.txt");
                Newfile.WriteLine(DefaultURL);
                Newfile.WriteLine(DefaultTimes);
                Newfile.WriteLine(DefaultInterval);
                Newfile.Close();
                Main(args);
            }
        }
        private static void AddSpam(string p)
        {

            ProcessStartInfo info = new ProcessStartInfo();
            info.FileName = "iexplore.exe";
            info.Arguments = p;
            info.WindowStyle = ProcessWindowStyle.Hidden;
            Process.Start(info);
        }
    }
}
Last edited on
LOL!

LOL!

? :O
i dont know if this is useful but i think that you have error on line 16.
it shoould be "View.Main2();"
Topic archived. No new replies allowed.