日期:2014-05-17 浏览次数:20918 次
private static string[] FoundFile; private static long Ntx; public static string[] SearchFileInPath(string thePath, string theFileName, bool mStop = false)//--------------这里 mStop As Boolean = False 报错 { if (Strings.Right(thePath, 1) != "\\") thePath = thePath + "\\"; GetFileLoop(thePath, theFileName, mStop); return FoundFile; } private static string GetFileLoop(string CurrentPath, string SearFile, bool mStop = false)//-------这里 mStop As Boolean = False 也报错 { string functionReturnValue = null; int nI = 0; int nDirectory = 0; long i = 0; string sFileName = null; string[] sDirectoryList = null; sDirectoryList = new string[-1 + 1]; // ERROR: Not supported in C#: OnErrorStatement sFileName = FileSystem.Dir(CurrentPath, Constants.vbHidden | Constants.vbDirectory | Constants.vbReadOnly | Constants.vbSystem);//--------------FileSystem.Dir在c#中是什么函数呢?Constants.也报错 while (!string.IsNullOrEmpty(sFileName)) { if (Strings.UCase(sFileName) // ERROR: Unknown binary operator Like//------------这里问题大了,要怎么改呢 ) { i = FileSystem.GetAttr(CurrentPath + sFileName); if ((i & Constants.vbDirectory) == 0) { if (mStop == false) { Array.Resize(ref FoundFile, Ntx + 1); FoundFile[Ntx] = CurrentPath + sFileName; Ntx = Ntx + 1; //Application.DoEvents() //Sleep(5) } else { functionReturnValue = CurrentPath + sFileName; return functionReturnValue; } } } if (sFileName != "." & sFileName != "..") { if (FileSystem.GetAttr(CurrentPath + sFileName) & Constants.vbDirectory) { nDirectory = nDirectory + 1; Array.Resize(ref sDirectoryList, nDirectory + 1);//--------错误 283 与“System.Array.Resize<string>(ref string[], int)”最匹配的重载方法具有一些无效参数,要怎么改呢? sDirectoryList[nDirectory] = CurrentPath + sFileName; } } sFileName = FileSystem.Dir(); } for (nI = 1; nI <= nDirectory; nI++) { functionReturnValue = GetFileLoop(sDirectoryList[nI] + "\\", SearFile); if (!string.IsNullOrEmpty(functionReturnValue) & mStop == true) break; // TODO: might not be correct. Was : Exit For//这里应该是exit for吧? } return functionReturnValue; }
Private FoundFile() As String '存放传回值的字串阵列 Private Ntx As Long Public Function SearchFileInPath(ByVal thePath As String, ByVal theFileName As String, Optional ByVal mStop As Boolean = False) As String()//-------这里 mStop As Boolean = False 也报错 If Strings.Right(thePath, 1) <> "\" Then thePath = thePath & "\" Call GetFileLoop(thePath, theFileName, mStop) SearchFileInPath = FoundFile End Function Private Function GetFileLoop(ByVal CurrentPath As String, ByVal SearFile As String, Optional ByVal mStop As Boolean = False) As String//-------这里 mStop As Boolean = False 也报错 Dim nI As Integer, nDirectory As Integer, i As Long Dim sFileName As String Dim sDirectoryList() As String ReDim sDirectoryList(-1) ' Ntx = 0 On Error Resume Next sF