protected override void Execute(NativeActivityContext context) { try { string filepath = FilePath.Get(context); var fileInfo = new FileInfo(filepath); FileName.Set(context, fileInfo.Name); FileExtension.Set(context, fileInfo.Extension); FileSize.Set(context, fileInfo.Length); CreationTime.Set(context, fileInfo.CreationTime); LastAccessTime.Set(context, fileInfo.LastAccessTime); LastWriteTime.Set(context, fileInfo.LastWriteTime); } catch (Exception ex) { Log.Logger.LogData(ex.Message + " in activity File_GetInformation", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
protected override void Execute(NativeActivityContext context) { try { string folderpath = FolderPath.Get(context); if (Directory.Exists(folderpath)) { var folderInfo = new FileInfo(folderpath); var dirInfo = new DirectoryInfo(folderpath); FolderName.Set(context, folderInfo.Name); // FolderCount.Set(context, folderInfo.Extension); // FileCount.Set(context, folderInfo.Length); FolderCount.Set(context, dirInfo.GetDirectories().Length); FileCount.Set(context, dirInfo.GetFiles().Length); CreationTime.Set(context, folderInfo.CreationTime); LastAccessTime.Set(context, folderInfo.LastAccessTime); LastWriteTime.Set(context, folderInfo.LastWriteTime); } else if (!Directory.Exists(folderpath)) { Log.Logger.LogData("Folder does not exist in path - " + folderpath + " in activity Folder_GetInformation", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } } catch (Exception ex) { Log.Logger.LogData(ex.Message + " in activity Folder_GetInformation", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }