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 void CallVSCode(string args)
         {
             System.Diagnostics.Process proc = new System.Diagnostics.Process();
             if(!VSCodeExists(CodePath))
             {
              PrintNotFound(CodePath);
              return;
             }

#if UNITY_EDITOR_OSX
             proc.StartInfo.FileName = "open";

             // Check the path to see if there is "Insiders"
             if (CodePath.Contains("Insiders"))
             {
                 proc.StartInfo.Arguments = " -n -b \"com.microsoft.VSCodeInsiders\" --args " + args.Replace(@"\", @"\\");
             }
             else
             {
                 proc.StartInfo.Arguments = " -n -b \"com.microsoft.VSCode\" --args " + args.Replace(@"\", @"\\");
             }

             proc.StartInfo.UseShellExecute = false;
#elif UNITY_EDITOR_WIN
             proc.StartInfo.FileName = CodePath;
          proc.StartInfo.Arguments = args;
             proc.StartInfo.UseShellExecute = false;
#else
             proc.StartInfo.FileName = CodePath;
          proc.StartInfo.Arguments = args.Replace(@"\", @"\\");
             proc.StartInfo.UseShellExecute = false;
#endif
             proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
             proc.StartInfo.CreateNoWindow = true;
             proc.StartInfo.RedirectStandardOutput = true;
             proc.Start();
         }