Vb.net 在文件中循环时的奇怪行为
这快把我们逼疯了,这应该行得通 运行时(步进) 它跳过debug.print(无错误) 然后它到达i+=1 从不在下一个(断点)停止 但是我=51 有什么线索吗Vb.net 在文件中循环时的奇怪行为,vb.net,visual-studio-2008,windows-7,Vb.net,Visual Studio 2008,Windows 7,这快把我们逼疯了,这应该行得通 运行时(步进) 它跳过debug.print(无错误) 然后它到达i+=1 从不在下一个(断点)停止 但是我=51 有什么线索吗 If CheckBox8.Checked = False Then Exit Function Else Dim fInfo As FileInfo() Dim i As Integer = 0 Dim dInfo As DirectoryInfo = New Di
If CheckBox8.Checked = False Then
Exit Function
Else
Dim fInfo As FileInfo()
Dim i As Integer = 0
Dim dInfo As DirectoryInfo = New DirectoryInfo(spath.ToString)
fInfo = dInfo.GetFiles("*.xml")
Dim sfiles As String()
Dim sFile As String
sfiles = Directory.GetFiles(spath, "*.xml")
For Each sFile In sfiles
Try
Debug.Print(sFile.ToString)
i += 1
Catch ex As Exception
Debug.Print(ex.Message)
End Try
Next
End If
此代码似乎工作正常
Imports System.IO
Module Module1
Sub Main()
Dim spath As String
spath = "C:\YOUR_DIRECTORY"
Dim fInfo As FileInfo()
Dim i As Integer = 0
Dim dInfo As DirectoryInfo = New DirectoryInfo(spath.ToString)
Try
fInfo = dInfo.GetFiles("*.xml")
For Each fi In dInfo.GetFiles("*.xml")
Dim file_name As String
file_name = fi.Name
Console.WriteLine(file_name)
i = i + 1
Next
Console.WriteLine("Found:" + i.ToString + " Files")
Catch ex As Exception
Console.Write(ex.Message)
End Try
End Sub
End Module
注意:Debug.Print将打印到Visual Studio中的“输出窗口”,而不是命令行,因此。。。。。如果没有打开“输出”窗口,则Debug.Print语句可能不太明显
这是因为您没有在调试配置中构建它吗?DEBUG.Print(sFile.ToString)同时打开了即时窗口和输出窗口