0

I am trying to store some data on a server as textfile or even as the class itself and then when the application loads it gets it and I can read and use from it as normal. internally it works just fine, I would like to store the class online so when something is needed to change I can just update the class file and the application will still run without needing to be re-downloaded / updated if you will.

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 options It is called like this

private void checkBox7_CheckedChanged(object sender)
    {
        if (checkBox7.Checked == true)
        {
            game.setmemory(Addresses.run, new byte[] { 0x00, 0x00 });
        }
        else
        {
            game.setmemory(Addresses.run, new byte[] { 0x00, 0x01 });
        }
    }

Again ideally I just want to store the "addresses Class" online either as a text file or even as the class.cs file itself, but if I can save it as a text file and read from it correctly I would prefer to just store it on pastebin. thank you as always for all help and information.

I can not seem to figure out how to save this "AddressesClass.cs" file on a server and use it in my application. I only want that file stored on the server. I right now am using it internally. 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 ?

Noob Coder
  • 11
  • 5
  • Confusing based on your question and comments below - if these are settings then a they probably should be in a settings file of your app. If they "change frequently" (as your comment), then save it to the file system (wherever, server, client, depending on context) - the structure can be anything that makes sense to you (e.g. JSON formatted, delimited, key/value, YAML, etc.). The file can be loaded/parsed whenever you deem fit. – EdSF Aug 19 '18 at 22:32
  • ouch, you just hurt my head. your response was all over the place (no offense whatsoever) but the comments below were based on his response. the original question is still as is. so How do I call to the "Addresses" class if it is stored on a server or in a text file on a server? – Noob Coder Aug 19 '18 at 22:39
  • I gave you different _options_. Nobody here knows the full context of your use case/s. If you look at ASP.Net applications, they have a `web.config` file where application settings can be found. Other types of .Net apps have [application and user settings](https://learn.microsoft.com/en-us/dotnet/framework/winforms/advanced/using-application-settings-and-user-settings). If they still don't meet your needs, then create a file that you can update, and read values from, whenever you need to. JSON, key/value, etc. are just format examples. – EdSF Aug 19 '18 at 22:49
  • you are telling me to store them locally on my PC when my question is asking how to store them on a server or even pastebin for the easiest route. i do NOT want to store the file on the PC. I would like it to be stored on the server all the time and never downloaded just used when the application is operating. now user download involved nor should the user ever see the file. so for example if I store AddressesClass.cs on my server how do I have the application on load get that class and use from it like the second set of code displays. – Noob Coder Aug 19 '18 at 22:52
  • Then the last item should suffice. You/your application will create and read files, stored wherever. If you don't understand how that works, update your question to be more specific - What kind of app are you talking about? Your tags don't point to ASP.net, so the assumption is local/desktop/console. If so, then storing data "on a server" means you'll have to communicate with network calls (http). – EdSF Aug 19 '18 at 22:57
  • I do not understand how that works I guess, so I am unsure how to ask the question since based on what I have asked it is not what I want? how do you suggest I ask the question. or do you understand what I am aiming at and know the answer and can maybe direct me / help me ? – Noob Coder Aug 19 '18 at 23:00
  • So what *can* you do? *Can* you read a file? *Can* you use those values instead of yours? *Can* you access that file if it's not on a local disk? It's hard to pick up where you got stuck when you don't tell us where *exactly* you are having problems. – nvoigt Aug 20 '18 at 08:46
  • I can not seem to figure out how to save this "AddressesClass.cs" file on a server and use it in my application. I only want that file stored on the server. I right now am using it internally. 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 ? – Noob Coder Aug 20 '18 at 20:01

2 Answers2

0

There's really no point in storing something like this on a server but ok:
1. Throw a file at your server that's the value as a byte array
2. Put a = BitConverter.ToUInt32(new WebClient().DownloadBytes("http://yourserver.com/filename")) after the value in your Addresses class
3. goto 1

chrissx
  • 13
  • 1
  • 5
-1

You can load c# code dynamically as described in this thread: execute c# code at runtime from code file But as was mentioned before you must use configuration files for such purpose.

Kirill Osadchuk
  • 222
  • 2
  • 8