vb 读取绝对路径的txt文件

来源:百度知道 编辑:UC知道 时间:2024/05/26 13:58:10
Private Sub Command1_Click()
Cls
Open App.Path & "\1.txt" For Input As #1
Do Until EOF(1)
Line Input #1, a
List1.AddItem a
Loop
Close #1
End Sub
以上实现了从相对路径读取1.txt文件内容

请问如何实现读取绝对路径的(比如d:\text\1.txt)的文件内容

Private Sub Command1_Click()
Cls
Open "d:\text\1.txt" For Input As #1
Do Until EOF(1)
Line Input #1, a
List1.AddItem a
Loop
Close #1
End Sub

Open "d:\text\1.txt" For Input As #1

Open "d:\text\1.txt" For Input As #1 就好了啊

直接把App.Path & "\1.txt"改成你的绝对路径d:\text\1.txt就可以了