tags:

views:

389

answers:

2

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

My.Computer.FileSystem.GetFiles(....)
+5  A: 

The My class is VB.NET specific.

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

winSharp93
Thanks for the help! :)
Tony
+1  A: 

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.

Rob P.
Agreed on both counts: doable, but an eye-roller.
Steven Sudit