public static void printFiles(IedConnection con, string prefix, string parent) { List<FileDirectoryEntry> files = con.GetFileDirectory (parent); foreach (FileDirectoryEntry file in files) { Console.WriteLine(prefix + file.GetFileName() + "\t" + file.GetFileSize() + "\t" + MmsValue.MsTimeToDateTimeOffset(file.GetLastModified())); if (file.GetFileName().EndsWith("/")) { printFiles (con, prefix + " ", parent + file.GetFileName()); } } }
public static void printFiles(IedConnection con, string prefix, string parent) { List <FileDirectoryEntry> files = con.GetFileDirectory(parent); foreach (FileDirectoryEntry file in files) { Console.WriteLine(prefix + file.GetFileName() + "\t" + file.GetFileSize() + "\t" + MmsValue.MsTimeToDateTimeOffset(file.GetLastModified())); if (file.GetFileName().EndsWith("/")) { printFiles(con, prefix + " ", parent + file.GetFileName()); } } }
private static IEnumerable <IEDFile> GetDownloadableFileList(IedConnection iedConnection, Device device, string directoryName) { //Get Files from Device: var files = iedConnection.GetFileDirectory(directoryName); var downloadableFileList = new List <IEDFile>(); var logDirectoryName = string.IsNullOrWhiteSpace(directoryName) ? "Root" : directoryName; Logger.Trace($"{device} - List IED Files on: {logDirectoryName}"); //Foreach file in the Device: //Check if file is a directoty or a file //If directory, recursive call with directory name //If file, and a valid download extension, add file to downloadable list foreach (var file in files) { var filename = file.GetFileName(); Logger.Trace($"{device} - {directoryName}{filename}"); if (filename.IsDirectory()) { downloadableFileList.AddRange(GetDownloadableFileList(iedConnection, device, directoryName + filename)); } else { if (!filename.IsDownloadable()) { continue; } var iedFile = new IEDFile() { CreationTime = file.GetLastModified(), FileSize = file.GetFileSize(), FileName = directoryName + filename, }; downloadableFileList.Add(iedFile); } } return(downloadableFileList); }