
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace httpdconf { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void make_btn_Click(object sender, EventArgs e) { Boolean flg_1; Boolean flg_2; Boolean flg_3; string conf_str; string stCurrentDir = System.Environment.CurrentDirectory; flg_1 = chk_text(host_name.Text); flg_2 = chk_text(ip_address.Text); flg_3 = chk_text(dc_root.Text); if (flg_1 && flg_2 && flg_3) { conf_str = @" <VirtualHost *:80> DocumentRoot " + dc_root.Text + host_name.Text + @" ServerName " + host_name.Text + @" " + option_text.Text + @" ErrorLog logs/virtual.host-" + host_name.Text + @"-error_log CustomLog logs/virtual.host-access-" + host_name.Text + @"_log combined </VirtualHost>"; midashi.Text = conf_str; IPAD.Text = ip_address.Text + " " + host_name.Text; wte(stCurrentDir, "/vhost-" + host_name.Text, midashi, "conf"); wte(stCurrentDir, "/hosts_win_" + host_name.Text, IPAD, "txt"); System.Diagnostics.Process.Start(stCurrentDir); } } public Boolean chk_text(string str) { if (str == "") { return (false); } return (true); } public void wte(string dir, string fname, TextBox txt_str, string ext) { System.IO.StreamWriter sw = new System.IO.StreamWriter( dir + fname + "." + ext, false, System.Text.Encoding.GetEncoding("utf-8")); foreach (string line in txt_str.Lines) { sw.Write(line + sw.NewLine); } sw.Close(); } private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { linkLabel1.LinkVisited = true; System.Diagnostics.Process.Start("https://twitter.com/zip358com"); } } }動作画面