Learn how to write the code to retrieve the command line arguments provided to the Command Prompt Project as part of the debug configuration in Visual Studio.
- [Instructor] First, let's extract…those Command Line Arguments we are expecting.…The apiKey, in my case,…will be the first Command Line Argument,…so args, for plural, args zero…would be the Command Line Argument containing our apiKey,…and we're expecting a filename in the second position,…but of course we need to make sure that these are valid.…So the first thing I'll do is for args one,…Ctrl + c to copy, and I'll say File.Exists.…
I do want to check that the file actually exists.…Ctrl + dot to say using System.IO,…so file is the class we need, file that exists.…If that is the case,…then we'll use that args one argument,…alternatively, we'll actually throw an exception,…the FileNotFoundException.…And so we'll have a little message there,…and then we'll specify the argument…that we were unhappy with.…
And so at this point, we're able to say look,…there is a requirement for apiKey,…and a requirement for the filename,…I'll just throw an exception if I don't find…what I'm expecting here.…Now, where is that message?…
Skill Level Intermediate
1. Problem 1: Pond Oreille
2. Problem 2: Where Am I?
3. Problem 3: Eight Queens
4. Problem 4: Accessing Peripherals
5. Problem 5: Facial Recognition
6. Problem 6: Real-Time Information Dashboard
Next steps2m 46s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.