File.WriteAllBytes(@"C:\Users\1\Desktop\123\smth.cs", WindowsFormsApp12.Properties.Resources.smth); 

Error: resources does not contain a definition for smth (underlines smth)

Essence: by clicking on the button you need to display the smth.cs file from the resources in the folder 123 on the desktop

  • Why should this code work? - tym32167
  • because I found it on stack, and in theory it should work :) - Konovalov Maxim
  • Try to understand the question and understand what your code is doing. I think you will quickly figure out where the problem is. - tym32167
  • smth is an abbreviation for something , i.e. given for example. Instead, you need to substitute the real name of your resource. smth.cs is a strange choice for a binary file name, since This extension is registered for text files of code written in C #. In short, you have written complete game, and therefore nothing works. - Bulson

2 answers 2

The Properties.Resources class contains auto-generated code for accessing project resources, each resource file has a property in this class. In order for "smth" to appear there, you need to add a resource of the same name in the project properties on the "Resources" tab.

    The essence of the answer lies in the fact that I in vain began to look for devious ways of outputting files, binary files or regular files, they need to output sample code https://www.youtube.com/watch?v=Tue13zNKzDs with the same brush. Of course, nothing is explained there , but without a bit of a head smack you will understand the essence.