[02/03] How to find whether we are in Dev environment
Hi,
How to find whether we are working in development environment ?
My requirement is the application I design has to save some data on some path if it is under development environment. if it is live environment then it has to save in live path.
let me know
thanks
Re: [02/03] How to find whether we are in Dev environment
You can use Command line arguments for this.
Re: [02/03] How to find whether we are in Dev environment
You pass command arguments to ur app like this:
"C:\WindowsApplication3.exe" "DEV"
and get the arguments in ur app like this:
vb.net Code:
Private Sub Form1_Load( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs _
) Handles MyBase.Load
Dim str As String
Dim args() As String
args = Environment.GetCommandLineArgs()
If args.Length > 0 Then
For Each str In args
MessageBox.Show(str)
Next
End If
End Sub
You can get the value of command line argument and do the stuff needed based on it.
Re: [02/03] How to find whether we are in Dev environment
Use conditional compilation:
vb.net Code:
#If DEBUG Then
'Code here will only be compiled into a Debug build.
#Else
'Code here will only be compiled into a Release build.
#End If
Note that the # symbols are part of the code. This is not a regular VB If statement. It is a directive to the compiler. the decision is not made at run time but rather at compile time. Only one of the code blocks will get compiled depending on the build configuration and there will be no If statement at run time.
Re: [02/03] How to find whether we are in Dev environment
Found solution myself.
vb Code:
Public Function IsApplicationRunningInIDE() As Boolean
IsApplicationRunningInIDE = System.Diagnostics.Debugger.IsAttached()
End Function
This will return true if we work in IDE and will return false if it is exe.
Thank you all for your help.