0

I am trying to store my data class on my server as is or even as a text file and then when the application loads it gets the class or text file and I can use it as normal.

Internally everything works just fine, but I can not seem to figure out how to load this "AddressesClass.cs" file from my server and use it in my application.

Once I put that file on my server where do I go from there? what do I do to load it into my application? and once it is loaded into the application do just call to it the same as before?

The class is formed like this:

public class Addresses
{
    public static uint run  = 0x00000001;
    public static uint walk = 0x00000002;
    public static uint jump = 0x00000003;
    public static uint sit  = 0x00000004;
}

and when I use one of the "Addresses" It is called like this

private void checkBox1_CheckedChanged(object sender)
{
    if (checkBox1.Checked)
         gamename.setmemory(Addresses.run, new byte[] { 0x00, 0x00 });
        }
        else
        {
         gamename.setmemory(Addresses.run, new byte[] { 0x00, 0x01 });
        }
}
Noob Coder
  • 11
  • 5
  • I think what you actually want to do is instantiate the class, not load it from a file. If the file is part of you project it will be included in the executable. Or are you trying to load specific values into the class? In that case you have a variety of options - take a look at File I/O for C#. – Tim Aug 21 '18 at 00:47
  • It seems you are describing a scripting system, or a plugin system. if this is just for data, then you probably just want a malleable data class and structure, like a dictionary or something, that can handle this domain and requirement. however i think you are most likely going down the wrong path with this whole load a C# class from a server implementation and this questions is most likely a little XY. what is your use case? – TheGeneral Aug 21 '18 at 00:50
  • 1
    Possible duplicate of [C# - Load a text file as a class](https://stackoverflow.com/questions/11750585/c-sharp-load-a-text-file-as-a-class) – vividpk21 Aug 21 '18 at 00:52
  • 1
    If that's all your saving, it appears to be more of a [settings file](https://msdn.microsoft.com/en-us/library/aa730869(v=vs.80).aspx) (which you can access through your program `Properties.Settings` class to read and write settings to the file). – Rufus L Aug 21 '18 at 01:01
  • I am unsure because my question is the best description I can give to ask for what I am aiming for. I just need to store that on my server and use it in the application. and in any event of your response what is the method to do so? the settings file is loaded from a server how ? – Noob Coder Aug 21 '18 at 01:07
  • There are _many_ ways to load a file from a server. Assuming it's web server, one of the easiest (although not the most modern ways) might be to use `WebClient`. You might also want to look into JSON or XML serialization (JSON is more common these days). – ProgrammingLlama Aug 21 '18 at 01:12
  • If i were to change it to an XML I wouldn't be able to call you to have it change memory the way the class method is called. – Noob Coder Aug 21 '18 at 01:17
  • I am still in need of assistance - I have looked at the recommended links and neither of them actually have any direct answer on how to use the "settings" loading the class into the application on load. if anyone can help please do. – Noob Coder Aug 21 '18 at 18:11
  • any chance on a more direct answer with some sort of instructions on what I am supposed to do since I have yet to figure this out. – Noob Coder Aug 30 '18 at 02:32

0 Answers0