各位大神 求救 文件夹文件路径读取写入问题
如何才能将一个文件夹内所有的文件路径改成超链接写进TXT
比如 D盘PIC文件夹下有1.jpg 2.doc 3.TXT 如何将这个文件夹里的这些文件路径加上超链接代码 写入TXT
要求运行后TXT写入内容为
<a href="D:\1.JPG">1</a>
<a href="D:\2.doc">2</a>
<a href="d:\3.txt">3</a>
[解决办法]
Dim txtText As String = ""
Dim names As String() = Directory.GetFiles("D:\PIC")
For i As Integer = 0 To names.Length - 1
txtText += "<a href=" + Chr(34) + Path.GetFileName(names(i)) + Chr(34) + ">" + Path.GetFileName(names(i)).Split(".")(0) + "</a>" + Chr(13)
Next
Dim streamWriter As IO.StreamWriter = New IO.StreamWriter("C:\a.txt", False, System.Text.Encoding.UTF8)
streamWriter.WriteLine(txtText)
streamWriter.Close()