Categories > Coding > C# >

have error in c# in resource

Posts: 1

Threads: 1

Joined: Dec, 2023

Reputation: 0

Posted

I want to put the programs for the application in the resource so that they do not take up space in the files. When I add them and make them extract to a specific place on the computer, this error appears. I want a solution.
https://cdn.discordapp.com/attachments/1219011433229189202/1219016142031687882/image.png?ex=6609c440&is=65f74f40&hm=a97140f13dbc6d43d47fd83eefa7a1d7c3c55bfddd69ea1e08520a31188cfa0c&

  • 0

Posts: 28

Threads: 7

Joined: Dec, 2020

Reputation: 0

Replied

I presume your adding them to the Resx file. In such case you can easily manipulate it. One of my projects does this.

 var resource = Properties.Resources.requiredfile;
 FileStream fileStream = new FileStream("My cool file.txt", FileMode.CreateNew);
 for (int i = 0; i < resource.Length; i++)
 fileStream.WriteByte((byte)resource[i]);
 fileStream.Close();

this code assumes the file is stored under the name "requiredfile" and that you want to save it to "My cool file.txt"

  • 0

Users viewing this thread:

( Members: 0, Guests: 1, Total: 1 )