Why is this code returning System.IO.FileInfo[]? and not a list of items named login.txt
Console.WriteLine("Searching for users wait...");
string username;
string password;
var fileList = new DirectoryInfo("C:").GetFiles("login.txt", SearchOption.AllDirectories);
string Lists = fileList.ToString();
Console.WriteLine(Lists);
var position = Lists.IndexOf("login");
if (position == -1)
{
Console.WriteLine("No users Found.... FUCK!!");
Console.WriteLine("Lets create a user. insert username");
username = Console.ReadLine();
Console.WriteLine("Add a password");
password = Console.ReadLine();
string loginData = username + " " + password;
try { System.IO.File.WriteAllText("C:", loginData); }
catch (System.UnauthorizedAccessException)
{
Console.WriteLine("I have no access to create a login file...");
Console.WriteLine("I will now to to gain access");
Process proc = new Process();
proc.StartInfo.FileName = "ConsoleApp2.exe";
proc.StartInfo.UseShellExecute = true;
proc.StartInfo.Verb = "runas";
proc.Start();
}
}
I need it to make a txt file that stores a username and a password, and i also need to search for that file, but i think im making something wrong here..
hope you'll help thanks