异步CTP新V3中的VB.Net收益 [英] VB.Net yield in async CTP new V3
问题描述
好的,我现在距离完成使该程序开始工作的目标还有3个错误,但是我正在使用的功能是这样的..
OK I am now 3 errors away from completing my goal of getting this program to work but the function I am using goes like this..
Public Iterator Function _matches(ByVal path As String) As IEnumerable(Of FileInfo)
Dim findData As New Win32.FindData()
Dim fileName As String
Using handle As Win32.SafeFindHandle = Win32.SafeNativeMethods.FindFirstFile(path.Combine(path, "*"), findData)
If Not handle.IsInvalid Then
Do
fileName = findData.fileName
If String.IsNullOrEmpty(fileName) Then
Continue Do
End If
If String.Equals(fileName, ".", StringComparison.Ordinal) Then
Continue Do
End If
If String.Equals(fileName, "..", StringComparison.Ordinal) Then
Continue Do
End If
' iff directory, dive into it
If 0 <> (CInt(FileAttributes.Directory) And findData.fileAttributes) Then
If m_includeSubDirs Then
For Each fi As FileInfo In _matches(path.Combine(path, fileName))
Yield Async(fi)
Next fi
End If
Else
For Each fileSpec As Regex In m_fileSpecs
If fileSpec.IsMatch(fileName) Then
Yield New FileInfo(path.Combine(path, fileName))
Exit For
End If
Next fileSpec
End If
Loop While Win32.SafeNativeMethods.FindNextFile(handle, findData)
End If
End Using
End Function
End Class
Microsoft已在异步迭代器中发布了新的yield,但是由于某些原因,它在3个地方给我带来了问题,而在使用"Path.Combine"指令的地方就给了我问题.....
听到的是我要通过此函数修复的确切行:
Microsoft has released the new yield in async iterator but it is for some reason giving me problems in 3 places giving Me problems where ever the instruction " Path.Combine " is used.....
Hear is the exact lines I am trying to fix from this Function:
(1). Using handle As Win32.SafeFindHandle = Win32.SafeNativeMethods.FindFirstFile(path.Combine(path, "*"), findData)
(2). For Each fi As FileInfo In _matches(path.Combine(path, fileName))
(3). Yield New FileInfo(path.Combine(path, fileName))
我希望我已经提供了有关我的问题的足够信息,因为我非常需要它来解决它.提前非常感谢大家:)
I hope I have given enough Information about my problem as I badly need it to work Thank you all very much in advance :)
推荐答案
对于Path错误,我认为问题在于您的函数接受一个path
参数,该方法实际上需要使用System.IO
命名空间中的Path
函数,并且使用了错误的函数.
将path.combine完全限定为System.IO.Path.Combine
,这应该可以解决该问题.
For the Path error, I think the problem lies in the fact that your function accepts apath
parameter, the method is actually needing to using thePath
function from theSystem.IO
namespace and is using the wrong one.
Fully qualify the path.combine toSystem.IO.Path.Combine
and that should sort that problem.
这篇关于异步CTP新V3中的VB.Net收益的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!