I was wandering if you can help with this. I have a console app which takes a string Directory as input.
I want to put in a check in place which allows me to check if a user puts in an empty string I want the system to log an error such as ArgumentNullException.
string inputDirectory = "";
private void DoSomething(string inputDirectory)
{
try
{
Directory.CreateDirectory(inputDirectory)
}
catch (ArgumentNullException e)
{
Log.Error("program failed because the directory supplied was empty", e.Message);
}
}
The code is somewhere along these lines. Now the problem I have is the exception does not get thrown. Instead the program assumes that the directory is in the bin\Debug folder of the project. I am not sure what I need to do to stop execution of the program if the directory provided is "". I have done the if(inputDirectory == null) but this has not worked. Any advice? Thanks, Jetnor.
Perhaps you can add a check like;