Esempio n. 1
0
        public void ToFile()
        {
            this.VhostsFile = DefaultVhostsFile;
            try
            {
                //this.writer = new StreamWriter("C:\\Users\\vlad_ko\\Desktop\\vhosts2.conf");
                this.writer = new StreamWriter(Vhosts.DefaultVhostsFile + ".tmp");
            }
            catch (FileNotFoundException)
            {
                Console.Error.WriteLine("cannot find the file");
            }
            catch (IOException)
            {
                MessageBox.Show("Dot Net Perls is the best.");
                Console.Error.WriteLine("cannot open the file");
            }

            using (this.writer)
            {
                this.writer.WriteLine("NameVirtualHost *");
                for (int i = 0; i < Vhosts.count; i++)
                {
                    this.writer.WriteLine("<VirtualHost *>");
                    this.writer.WriteLine(" DocumentRoot " + this.GetVhostDRAt(i).Trim());
                    this.writer.WriteLine(" ServerName " + this.GetVhostSNAt(i).Trim());
                    this.writer.WriteLine("</VirtualHost>");
                }
            }
            File.Copy(Vhosts.DefaultVhostsFile + ".tmp", Vhosts.DefaultVhostsFile, true);
            HostFile hosts = new HostFile();

            hosts.ToFile();
        }
Esempio n. 2
0
        public void ToFile()
        {
            this.VhostsFile = DefaultVhostsFile;
            try
            {
                //this.writer = new StreamWriter("C:\\Users\\vlad_ko\\Desktop\\vhosts2.conf");
                this.writer = new StreamWriter(Vhosts.DefaultVhostsFile+".tmp");
            }
            catch (FileNotFoundException)
            {
                Console.Error.WriteLine("cannot find the file");
            }
            catch (IOException)
            {
                MessageBox.Show("Dot Net Perls is the best.");
                Console.Error.WriteLine("cannot open the file");
            }

            using (this.writer)
            {
                this.writer.WriteLine("NameVirtualHost *");
                for (int i = 0; i < Vhosts.count; i++)
                {
                    this.writer.WriteLine("<VirtualHost *>");
                    this.writer.WriteLine(" DocumentRoot "+this.GetVhostDRAt(i).Trim());
                    this.writer.WriteLine(" ServerName "+this.GetVhostSNAt(i).Trim());
                    this.writer.WriteLine("</VirtualHost>");
                }
            }
            File.Copy(Vhosts.DefaultVhostsFile + ".tmp", Vhosts.DefaultVhostsFile,true);
            HostFile hosts = new HostFile();
            hosts.ToFile();
        }