简体   繁体   中英

VB6 to C# line of code

What exactly is this line of code doing in vb6?

  If StrConv(Dir(FilePath & strArray(ArrayCounter)), vbUpperCase) <> StrConv(strArray(ArrayCounter), vbUpperCase)

It seems like its comparing the exact same thing here...

Filepath is just a string with a directory name in it

It's testing for the existence of the file strArray(ArrayCounter) in the directory FilePath.

If the file exists, Dir will return the filename without the path, and the comparison will succeed.

If the file doesn't exist, Dir will return an empty string, and the comparison will fail.

If strArray(ArrayCounter) contains a wildcard character, the result of the Dir function will be the first matching filename, and the comparison will fail.

The MSDN documentation for the Dir function covers this, and you can also see what's happening quite easily by running the code with the VB6 debugger (or VBA debugger if you don't have VB6).

它以不区分大小写的方式检查Dir(FilePath & strArray(ArrayCounter))strArray(ArrayCounter)是否不相等。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM