Hello friends....

I have to check the folder path in such a way that

c:\Pooja\dynamic_folder\Output.txt

From Pooja folder how will I be able to move to the text file since the dynamic folder can be anything and I want to move inside the dynamic folder...

is there any way...

i tried this

Dim path As String
        path = "C:\Pooja\Images\dynamic\PatientRegEntry.txt"
        Debug.Print("Path: " + path)

Hello friends....

I have to check the folder path in such a way that

c:\Pooja\dynamic_folder\Output.txt

From Pooja folder how will I be able to move to the text file since the dynamic folder can be anything and I want to move inside the dynamic folder...

is there any way...

i tried this

Dim path As String
        path = "C:\Pooja\Images\dynamic\PatientRegEntry.txt"
        Debug.Print("Path: " + path)

The above code got solved but I need to replace a particular string with another word...but the string is not showing any effect

Imports System.IO
Imports System.Text.RegularExpressions

Public Class frmOutput
    Dim path As String
    Private Sub frmOutput_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim dig As DirectoryInfo = New DirectoryInfo("C:\Pooja\Images\")
        Dim number As Integer
        number = System.IO.Directory.GetDirectories(dig.ToString).Length
        ListBox1.Items.Clear()
        If number = 0 Then
            MsgBox("No files found")
        Else
            Dim di As New IO.DirectoryInfo("C:\Pooja\Images\")
            Dim diar1 As IO.DirectoryInfo() = di.GetDirectories()
            Dim dra As IO.DirectoryInfo
            For Each dra In diar1
                ' ListBox1.Items.Add(dra)
                Dim filename As FileInfo = New FileInfo("C:\Pooja\Images\" + dra.ToString + "\PatientRegEntry.txt")
                If dra.ToString <> "DataBackup" Then
                    If Not filename.Exists Then
                        Debug.Print("File absent: " + filename.ToString)
                    Else
                        Debug.Print("File present: " + filename.ToString)
                        Dim fName As String = "C:\Pooja\Images\" + dra.ToString + "\PatientRegEntry.txt"               'path to text file
                        Dim testTxt As New StreamReader(fName)
                        Dim allRead As String = testTxt.ReadToEnd()
                        Debug.Print("allRead: " + allRead)
                        Dim regMatch As String = "000Y"
                        If Regex.IsMatch(allRead, regMatch) Then
                            Debug.Print("In Loop")
                            allRead = Replace(allRead, "000Y", "empty")
                        Else
                            Debug.Print("Else Loop")
                        End If
                        ListBox1.Items.Add(dra)
                    End If
                Else
                    Debug.Print("DataBackup")
                End If
            Next
        End If
    End Sub
End Class

I want to replace the "000Y" string in the text file to "empty"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.