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 WriteWorkspaceSettings()
         {
             if (Debug)
             {
                 UnityEngine.Debug.Log("[VSCode] Workspace Settings Written");
             }

             if (!Directory.Exists(VSCode.SettingsFolder))
             {
                 System.IO.Directory.CreateDirectory(VSCode.SettingsFolder);
             }

             string exclusions =
                 // Associations
                 "{\n" +
                 "\t\"files.associations\":\n" +
                 "\t{\n" +
                 "\t\t\"*.bjs\":\"javascript\",\n" +
                 "\t\t\"*.javascript\":\"javascript\"\n" +
                 "\t},\n" +
                 "\t\"files.exclude\":\n" +
                 "\t{\n" +
                 // Hidden Files
                 "\t\t\"**/.DS_Store\":true,\n" +
                 "\t\t\"**/.git\":true,\n" +
                 "\t\t\"**/.gitignore\":true,\n" +
                 "\t\t\"**/.gitattributes\":true,\n" +
                 "\t\t\"**/.gitmodules\":true,\n" +
                 "\t\t\"**/.svn\":true,\n" +


                 // Project Files
                 "\t\t\"**/*.booproj\":true,\n" +
                 "\t\t\"**/*.pidb\":true,\n" +
                 "\t\t\"**/*.suo\":true,\n" +
                 "\t\t\"**/*.user\":true,\n" +
                 "\t\t\"**/*.userprefs\":true,\n" +
                 "\t\t\"**/*.unityproj\":true,\n" +
                 "\t\t\"**/*.dll\":true,\n" +
                 "\t\t\"**/*.exe\":true,\n" +

                 // Media Files
                 "\t\t\"**/*.pdf\":true,\n" +

                 // Video
                 "\t\t\"**/*.mp4\":true,\n" +

                 // Audio
                 "\t\t\"**/*.mid\":true,\n" +
                 "\t\t\"**/*.midi\":true,\n" +
                 "\t\t\"**/*.wav\":true,\n" +
                 "\t\t\"**/*.mp3\":true,\n" +
                 "\t\t\"**/*.ogg\":true,\n" +

                 // Textures
                 "\t\t\"**/*.gif\":true,\n" +
                 "\t\t\"**/*.ico\":true,\n" +
                 "\t\t\"**/*.jpg\":true,\n" +
                 "\t\t\"**/*.jpeg\":true,\n" +
                 "\t\t\"**/*.png\":true,\n" +
                 "\t\t\"**/*.psd\":true,\n" +
                 "\t\t\"**/*.tga\":true,\n" +
                 "\t\t\"**/*.tif\":true,\n" +
                 "\t\t\"**/*.tiff\":true,\n" +
                 "\t\t\"**/*.hdr\":true,\n" +
                 "\t\t\"**/*.exr\":true,\n" +

                 // Models
                 "\t\t\"**/*.3ds\":true,\n" +
                 "\t\t\"**/*.3DS\":true,\n" +
                 "\t\t\"**/*.fbx\":true,\n" +
                 "\t\t\"**/*.FBX\":true,\n" +
                 "\t\t\"**/*.lxo\":true,\n" +
                 "\t\t\"**/*.LXO\":true,\n" +
                 "\t\t\"**/*.ma\":true,\n" +
                 "\t\t\"**/*.MA\":true,\n" +
                 "\t\t\"**/*.obj\":true,\n" +
                 "\t\t\"**/*.OBJ\":true,\n" +

                 // Unity File Types
                 "\t\t\"**/*.asset\":true,\n" +
                 "\t\t\"**/*.cubemap\":true,\n" +
                 "\t\t\"**/*.flare\":true,\n" +
                 "\t\t\"**/*.mat\":true,\n" +
                 "\t\t\"**/*.meta\":true,\n" +
                 "\t\t\"**/*.prefab\":true,\n" +
                 "\t\t\"**/*.unity\":true,\n" +

                 // Folders
                 "\t\t\"build/\":true,\n" +
                 "\t\t\"Build/\":true,\n" +
                 "\t\t\"Library/\":true,\n" +
                 "\t\t\"library/\":true,\n" +
                 "\t\t\"obj/\":true,\n" +
                 "\t\t\"Obj/\":true,\n" +
                 "\t\t\"ProjectSettings/\":true,\r" +
                 "\t\t\"temp/\":true,\n" +
                 "\t\t\"Temp/\":true\n" +
                 "\t}\n" +
                 "}";

             // Dont like the replace but it fixes the issue with the JSON
             File.WriteAllText(VSCode.SettingsPath, exclusions);
         }