Copying and Pasting cs Code

In cs, like in almost any computer programming language, reading data from a file can be tricky. You add extra lines of code to tell the computer what to do. Sometimes you can copy and paste these lines from other peoples’ code.

For example, you can follow the pattern in this listing:

         static string AutodetectCodePath()
         {
             string[] possiblePaths =
#if UNITY_EDITOR_OSX
             {
                 "/Applications/Visual Studio Code.app",
                 "/Applications/Visual Studio Code - Insiders.app"
             };
#elif UNITY_EDITOR_WIN
             {
                 ProgramFilesx86() + Path.DirectorySeparatorChar + "Microsoft VS Code"
                 + Path.DirectorySeparatorChar + "bin" + Path.DirectorySeparatorChar + "code.cmd",
                 ProgramFilesx86() + Path.DirectorySeparatorChar + "Microsoft VS Code Insiders"
                 + Path.DirectorySeparatorChar + "bin" + Path.DirectorySeparatorChar + "code-insiders.cmd"
             };
#else
             {
                 "/usr/bin/code",
                 "/bin/code",
                 "/usr/local/bin/code"
             };
#endif
             for(int i = 0; i < possiblePaths.Length; i++)
             {
                 if(VSCodeExists(possiblePaths[i]))
                 {
                     return possiblePaths[i];
                 }
             }
             PrintNotFound(possiblePaths[0]);
             return possiblePaths[0]; //returns the default one, printing a warning message 'executable not found'
         }