폴더에서 파일이름 가져오기 , txt 읽기
*
Imports System.IO

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x As Integer = 0
Dim array(10) As String
For Each foundFile As String In My.Computer.FileSystem.GetFiles(My.Computer.FileSystem.SpecialDirectories.MyDocuments, FileIO.SearchOption.SearchTopLevelOnly, "*.txt")

Dim fi As New IO.DirectoryInfo(foundFile)

ListBox1.Items.Add(fi.Name)

array(x) = fi.Name.ToString


ListBox2.Items.Add(array(x))
x += 1

Next

Label1.Text = array(0)


Try

Dim Lines() As String = IO.File.ReadAllLines(My.Computer.FileSystem.SpecialDirectories.MyDocuments & "/" & array(0))
For xx As Integer = 0 To Lines.Length - 1
TextBox1.Text += Lines(xx) & vbCrLf
Next

Catch ex As Exception

End Try


End Sub
End Class

zzaa.PNG

 

 

 

 

각 foundFile 문자열에 대해 My.Computer.FileSystem.GetFiles (My.Computer.FileSystem.SpecialDirectories.MyDocuments, FileIO.SearchOption.SearchTopLevelOnly, "* .txt")

 

이 게시물을

공유하기

SEARCH

MENU NAVIGATION