[Off-topic] dbzfanatic:
More Code Examples:​

Since I'm working on a project with another member here that requires me learning C# I thought I'd post some of my practice code. It's all functional.

C#

Common Functions:

using System.Windows.Forms;
using System;
using System.IO;
using System.Threading;
using System.Collections.Generic;

namespace Common
{
public class CommonFunctions{

public static void MsgBox(string sMessage, string sCaption = "Error", MessageBoxButtons buttons = MessageBoxButtons.OK, MessageBoxIcon Icon = MessageBoxIcon.Exclamation, IWin32Window owner = null)
{
MessageBox.Show(owner, sMessage, sCaption, buttons, Icon);
}

public static void Test(params string[] sInput)
{
for (int i = 0; i < sInput.Length; i++)
{
Console.WriteLine(sInput[i]);
}
}

public static void Sleep(int iMilliseconds)
{
Thread.Sleep(iMilliseconds);
}

public static string StringStripCR(string sInput)
{
string sNewString = sInput.Replace(Convert.ToString(Convert.ToChar(10)), "");
sNewString = sNewString.Replace(Convert.ToString(Convert.ToChar(13)), "");
return sNewString;
}

public static string[] DriveGetDrive(string sType){
DriveInfo[] ListDrives = DriveInfo.GetDrives();
List<string> lList = new List<string>();
DriveType dType = new DriveType();
int iDriveNum = 0;
lList.Add(Convert.ToString(iDriveNum));

if((sType == "removable") || (sType == "Removable")){
dType = DriveType.Removable;
}
else if((sType == "network") || (sType == "Network")){
dType = DriveType.Network;
}
else if ((sType == "Fixed") || (sType == "fixed"))
{
dType = DriveType.Fixed;
}
else if ((sType == "CDRom") || (sType == "cdrom") || (sType == "CDrom"))
{
dType = DriveType.CDRom;
}

foreach (DriveInfo sDrive in ListDrives)
{
if(sDrive.DriveType.Equals(dType))
{
string sDriveString = Convert.ToString(sDrive);
lList.Add(sDriveString.Remove(sDriveString.Length - 1,1));//Add to RemovableDrive list
}
}
lList[0] = Convert.ToString(lList.Count - 1);
string[] aDrives = lList.ToArray();

return aDrives;
}
}
}

CWCheat Database Fixer:

using Common;
using System.IO;
using System;

public class MainRun:CommonFunctions
{

static void Main()
{
string path = "";
string[] aDrives = DriveGetDrive("removable");
int iMax = Convert.ToInt16(aDrives[0]);

for(int i = 2;i <= iMax; i++){
if (Directory.Exists(aDrives[i] + "\\seplugins\\"))
{
path = aDrives[i] + "\\seplugins\\cwcheat\\cheat.db";
}

}

if((path==""))
{
MsgBox("No database detected\n\nExiting...");
Environment.Exit(0);
}

string sFileContents = File.ReadAllText(path);
string sCleared = StringStripCR(sFileContents);
sCleared = sCleared.Replace("_", "\r\n_");
sCleared = sCleared.Remove(0, 1);
File.WriteAllText(path, sCleared);
}
}

Autoit

CWCheat Database Fixer:

#include <File.au3>

$path = ""

$drives = DriveGetDrive("removable")
for $i = 2 to $drives[0]
if FileExists($drives[$i] & "\seplugins") Then
$path = $drives[$i] & "\seplugins\cwcheat\cheat.db"
EndIf
Next

if $path = "" Then
MsgBox(48,"Error","No database detected." & @CRLF & @CRLF & "Exiting...")
Exit
EndIf

$file = FileOpen($path,0)
$data = StringReplace(StringReplace(StringStripCR(FileRead($file)),"_", @CRLF & "_"),@cr,"",1)
$file = FileOpen($path,2)
FileWrite($file,$data)

Now the two DB fixers work exactly the same in exactly the same way with exactly the same result. Oddly enough the c# version was slower on my system than the autoit version, but considerably smaller. It may just be something quirky with my system but I thought I'd let you know. Since they work the same it's easy to look at the code and "translate" between the two.