Функцию ReadFile контент из каталог (1.txt-9999.txt) с диапазоном(1233.txt -12234.txt)
У меня есть проблема я хочу прочитать определенный диапазон файлов из каталога
p0.txt чтобы p9999.txt.
я хочу читать только текстовые файлы из p1234.txt -p1255.txt с помощью текстового ввода можно выбрать диапазон.
и обрабатывать содержимое каждого файла
Любая помощь будет высоко оценена .
Спасибо
Что я уже пробовал:
Option Strict On Option Explicit On Option Infer Off Imports System.IO Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click With OpenFileDialog1 .FileName = "" .Title = "Open Text File" .InitialDirectory = "C:\Users\mks\Desktop\newonlindup" .Filter = "Sp1|*.sp1" .ShowDialog() End With Dim path As String = System.IO.Path.GetFileName(OpenFileDialog1.FileName) TextBox1.Text = Path End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click With OpenFileDialog1 .FileName = "" .Title = "Open Text File" .InitialDirectory = "C:\Users\mks\Desktop\newonlindup" .Filter = "Sp1|*.sp1" .ShowDialog() End With Dim path As String = System.IO.Path.GetFileName(OpenFileDialog1.FileName) TextBox2.Text = path End Sub Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click Dim z As String Dim a As String z = TextBox1.Text Console.WriteLine(z.Substring(1, z.Length - 5)) a = TextBox2.Text Console.WriteLine(a.Substring(1, a.Length - 5)) If TextBox1.Text = "" Or TextBox2.Text = "" Then MsgBox("Please fill all text boxes") ElseIf z.Substring(1, z.Length - 5) > a.Substring(1, a.Length - 5) Then Console.WriteLine("great") MsgBox("FROM value Should be greater than TO") TextBox2.Focus() End If TextBox3.Text = TextBox1.Text End Sub Private Sub Button4_Click(sender As Object, e As PaintEventArgs) Handles Button4.Paint ' Private Sub Form1_Load(sender As Object, e As PaintEventArgs) Handles MyBase.Paint Dim g As Graphics = e.Graphics Dim strTextFromFile As String = IO.File.ReadAllText("C:\Users\mks\Desktop\newonlindup\" + "p1234.SP1") Dim strResults As String = String.Empty For Each c As Char In strTextFromFile If IsNumeric(c) Then strResults += c End If Next 'g.DrawString(strResults, New Font("Consolas", 12), Brushes.Red, New Point(10, 10)) MsgBox(strResults) Dim path As String = System.IO.Path.GetFileName(OpenFileDialog1.FileName) End Sub End Class