Monthly Archives: May 2012

Repair internet connection in c# program

I need to reset internet connection from the c# program like the way through user interface. So I go through google, and end up with the code below:
Target OS: windows xp

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

namespace netreset
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void timer1_Tick(object sender, EventArgs e)
{
Runcommand("arp", "-d *");
Runcommand("ipconfig", "/flushdns");
Runcommand("ipconfig", "/registerdns");
Console.WriteLine(".");
}

private static void Runcommand(string filename, string parameter)
{
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = filename;
info.Arguments = parameter;
info.CreateNoWindow = true;
info.WindowStyle = ProcessWindowStyle.Hidden;
Process p = Process.Start(info);
p.WaitForExit(1000);

}

}
}

install and config subversion on debian

install is easy, this is the steps to set the server to run everytime system starts, hope there could be an easier way to do so like in windows setup exe in the future.

1 create script

cd /etc/init.d/
touch svnserve
vi svnserve

2 content of the script

#!/bin/bash
### BEGIN INIT INFO
# Provides:          svnserve
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:
# Default-Stop:
# X-Interactive:     true
# Short-Description: Start/stop svnserve
### END INIT INFO

svnserve -d -r /usr/local/svn/repository_name

3 enable executable privilege
chmod +x svnserve

4 set the script to run when system starts
update-rc.d svnserve defaults