The program must create a .html file. It is necessary to unpack jquery.js, jquery-ui.js from the application in the same folder. I can not understand how to implement it. What are some ideas?
- What does "right" mean? Do you have any ways in mind and you do not know which one to choose? (Then voice the methods and criteria of correctness) Or "without any concept at all" and can you recommend any (say, copy two files from the dist folder) method? - AK ♦
- oneWays to solve this problem - a lot! For example, the basic ones are: download from the Internet, copy a file from a specific directory, copy a file from resources, generate a file. So I would like more specifics and see your attempts too, would be useful ... - EvgeniyZ
- "no idea at all" - axmed2004
- opened the project properties, the resources tab, the "add resource" button with the "File" type does not work - axmed2004
- You know, let's not make sharp jumps from "A" to "K", let's gradually: A -> B -> C ... At first you said that you have no ideas. After that, you need to voice some sort of action algorithm, and not rush to open the properties of the project. You have the last comment hanging in the air - it is not clear which path you have chosen. Give your idea how to do it - then it will be clear what is not working. (Maybe you generally do not need that tab with the selected method). Add a question by clicking "edit" if you have a specific idea and there is a specific implementation complexity. - AK ♦
1 answer
When we add something to the resources, we automatically receive the data that is in this file. If this image - we get Bitmap or its analogs, if a text file - we get string , if this is a file - we will most likely get byte[] . Knowing the type, we can safely use the File class and write the necessary data to disk.
Let's take a simple example:
- Click on the project with the right mouse button - properties.
- On the side, select
Ресурсы. - In the window that appears, it can write that there are no resources - feel free to create it.
- We transfer our file to this window with the mouse.
- On the side of the properties menu, we can look at the type of this file, in the same place we can make it a simple set of bytes (by setting Binary)
Now we can work with this resource as we want. For example, we write all the information from a file to a disk:
File.WriteAllText("jquery-3.3.1.js", Properties.Resources.jquery_3_3_1);
Here we call the usual WriteAllText() method which writes the entire string to a file. If we put the Binary type in the resource properties for example, then we can also write the file, but using a different method (WriteAllBytes):
File.WriteAllBytes("jquery-3.3.1.js", Properties.Resources.jquery_3_3_1); If for example we have an image, then there is a slightly different approach. So, as our image gets the Bitmap type, we can save it as bytes, or we can safely use the Bitmap save method (Save):
Properties.Resources.cha_elf.Save("img.png"); As you can see, it all depends on the type of data we store in the resources.
So good luck learning C #!
