VB.NET to C# - my.computer.getfiles()

前端 未结 2 678
野性不改
野性不改 2021-01-18 08:13

What is the equivalent C# code for this VB.NET code?

My.Computer.FileSystem.GetFiles(....)
相关标签:
2条回答
  • 2021-01-18 08:36

    The My class is VB.NET specific.

    You can use the static methods of the System.IO.Directory class - e.g. Directory.GetFiles.

    0 讨论(0)
  • 2021-01-18 08:40

    You can use the VB.Net's "My" in C#. It's all code, after all. In your C# project, you'd simply add a reference to Microsoft.VisualBasic

    You can check out a more detailed explanation here:

    http://www.codeproject.com/KB/cs/MyNamespace.aspx

    I don't think there is anything in 'My' that you can't achieve without using it; but just because you aren't programming in VB.Net you have to not use it.

    Having said all that - most architect type people I know would roll their eyes at you if they saw you adding a reference to VisualBasic in a C# project. But it's totally doable.

    0 讨论(0)
提交回复
热议问题