HI all,
as i discussed in the previous doubts im still resolving it, i need some help from you side also
if you want to know more go through the VB Script its helps please check this i tried to fix it but im facing many trouble like variable type and some are cant fixed
Mainevent(Autosaved).xaml (21.0 KB)
Assign fileList = Directory.GetFiles("C:\YourDirectory", “*.txt”)
Assign textsToFind = New List(Of String)
textsToFind.Add(“Branch”)
textsToFind.Add(“Asso”)
textsToFind.Add(“COMMUNITY”)
textsToFind.Add(“INC”)
textsToFind.Add(“Association”)
Assign fileCount = 0
For Each filePath In fileList
Assign fileContent = File.ReadAllText(filePath)
For Each searchText In textsToFind
// Search for the current text within the file content
If fileContent.Contains(searchText)
Then
// Increment the fileCount when the condition is met
Assign fileCount = fileCount + 1
// Split the content into words
Assign words = fileContent.Split({" "}, StringSplitOptions.RemoveEmptyEntries)
// Find the index of the search text
Assign searchTextIndex = Array.IndexOf(words, searchText)
// Extract two words before and two words after
Assign wordsBeforeAndAfter = New List(Of String)
For i = Math.Max(0, searchTextIndex - 2) To Math.Min(words.Length - 1, searchTextIndex + 2)
wordsBeforeAndAfter.Add(words(i))
Next
// Join the extracted words into a sentence
Assign contextSentence = String.Join(" ", wordsBeforeAndAfter)
Log Message - Message: "Found in file: " + filePath + " - Context: " + contextSentence
// Perform additional actions with the extracted context sentence
End If
End For Each
Next
Log Message - Message: "Total files found: " + fileCount.ToString