// Extract data from the directory static void ExtractImageData() { Student student = new Student() { AbsoluteUrl = Constants.FTP.BaseUrl }; string directory = "200423859 Junseob Noh"; // To store StudentId, FirstName, and LastName student.FromDirectory(directory); string infoFilePath = student.FullPathUrl + "/" + Constants.Locations.InforFile; bool fileExists = FTPApp.FileExists(infoFilePath); if (fileExists == true) { byte[] bytes = FTPApp.DownloadFileBytes(infoFilePath); string csvData = Encoding.Default.GetString(bytes); string[] csvlines = csvData.Split("\r\n", StringSplitOptions.RemoveEmptyEntries); if (csvlines.Length != 2) { Console.WriteLine("Error in CSV format"); } else { student.FromCSV(csvlines[1]); Console.WriteLine(">>> myimage.jpg file as Base64:"); Console.WriteLine(student.ImageData); } } }
static List <Student> CollectStudentInfor() { List <Student> students = new List <Student>(); // fetch the diretoreis info files and Images, and then display the console them. List <string> directories = FTPApp.GetDirectory(Constants.FTP.BaseUrl); foreach (var directory in directories) { Student student = new Student() { AbsoluteUrl = Constants.FTP.BaseUrl }; // To store StudentId, FirstName, and LastName student.FromDirectory(directory); string infoFilePath = student.FullPathUrl + "/" + Constants.Locations.InforFile; bool fileExists = FTPApp.FileExists(infoFilePath); if (fileExists == true) { byte[] bytes = FTPApp.DownloadFileBytes(infoFilePath); string csvData = Encoding.Default.GetString(bytes); string[] csvlines = csvData.Split("\r\n", StringSplitOptions.RemoveEmptyEntries); if (csvlines.Length != 2) { Console.WriteLine($"{student.FirstName} {student.LastName} has Error in CSV format"); } else { student.FromCSV(csvlines[1]); } if (student.StudentId == "200423859") { student.MyRecord = true; } else { student.MyRecord = false; } } else { Console.WriteLine($"{student.FirstName} {student.LastName} Could not find info file:"); } students.Add(student); } return(students); }