views:

1160

answers:

4

What are the best C# (csharp) equivalents for the following VB (VB.NET, VisualBasic) statements:

My.Application.Info.DirectoryPath

My.Computer.Clipboard

My.Computer.Audio.PlaySystemSound()

My.Application.Shutdown()
+3  A: 

Check out My For C# at IDesign.NET. Blog post about it here.

JP Alioto
+2  A: 

This may not be exactly what you're looking for, but just in case you want to take a shortcut, if you add a reference to the Microsoft.VisualBasic assembly, you can use the nifty tools VB programmers have access via the MyServices namespace.

Miky Dinescu
good shortcut, but yes, I was looking for universal alternatives. I'm sure this will help someone though.
Aaron Hoffman
+3  A: 

Application.ExecutablePath

System.Windows.Forms.Clipboard

System.Media.*

Application.Exit

TheCodeMonk
These are probably correct for a Windows Forms App
Aaron Hoffman
A: 

If you are converting a WPF application, you can use the following:

System.Reflection.Assembly.GetExecutingAssembly().Location;
//gets file path with file name

System.Windows.Clipboard;

System.Media.SystemSounds.[Sound].Play();

System.Windows.Application.Current.Shutdown();
Aaron Hoffman