Friday, November 23, 2012

C# Tutorial: How to create a program that self replicates!

// Namespaces that you need
using System.Diagnostics;
using System.IO;

// The Replication Code
for (int i = 1; i <= 5; i++)
{
    string exec = Application.ExecutablePath;
    exec = exec.Insert(exec.IndexOf("."), i.ToString());
    File.Copy(Application.ExecutablePath, exec);
    Process.Start(exec);
}
// You can replace 5 with whatever number you want
// However, be carefull!