Beginner needs help with project

So I recently purchased an Arduino Uno Rev3 from Radioshack for $35. (Later seen online for <20) in hopes of transferring some functions over to it for use with my Xbox repair services. I have what I believe to be all the coding needed, however I have no idea how to implement into the r3 board. The code below is C# and pc based. I also have a hex file used in a board that once preformed this function for me. I used Xloader to try and load it once but after 20 mins I exited. Would it be possible to use this code on the board? I am sure it needs altering tho.

    using System;
    using System.IO;
    using x360Utils.NAND;

    public class BasicNANDReader: IDisposable {
        public BasicNANDReader(string file): this(File.OpenRead(file)) { }

        public BasicNANDReader(Stream input)
        {
            BaseStream = input;
            CheckMagic();
            CheckForMeta();
        }

        public bool HasSpare { get; internal set; }

        public long Length {
            get {
                if(!HasSpare)
                    return BaseStream.Length;
                return (BaseStream.Length / 0x210) * 0x200;
            }
        }

        public long Position {
            get {
                if(!HasSpare)
                    return BaseStream.Position;
                return (BaseStream.Position / 0x210) * 0x200 + BaseStream.Position % 0x210;
            }
            set { SetPosition(value); }
        }

        public Stream BaseStream { get; private set; }

        public void Dispose() { BaseStream.Dispose(); }

        internal virtual void SetPosition(long offset) { Seek(offset, SeekOrigin.Begin); }

        internal void CheckMagic() {
            BaseStream.Seek(0, SeekOrigin.Begin);
            var buf = new byte[2];
            BaseStream.Read(buf, 0, 2);
            if(buf[0] != 0xFF || buf[1] != 0x4F)
                throw new NANDReaderException(NANDReaderException.ErrorTypes.BadMagic, string.Format("Expected: 0xFF4F Got: 0x{0:X2}{1:X2}", buf[0], buf[1]));
        }

        internal void CheckForMeta() {
            BaseStream.Seek(0, SeekOrigin.Begin);
            var buf = new byte[0x630]; // 3 page buffer
            if(BaseStream.Read(buf, 0, buf.Length) != buf.Length)
                throw new NANDReaderException(NANDReaderException.ErrorTypes.NotEnoughData);
            HasSpare = true; // Let's assume it has spare before we begin...
            for(var i = 0; i < buf.Length; i += 0x210) {
                if(!Meta.CheckPageEcd(ref buf, i))
                    HasSpare = false; // We don't have spare...
            }
        }

        public void Close() { BaseStream.Close(); }

        public virtual int Read(byte[] buffer, int offset, int count) {
            if(!HasSpare)
                return BaseStream.Read(buffer, offset, count);
            var read = 0;
            if(BaseStream.Position % 0x210 > 0) {
                int pageOffset = (int)(0x200 - BaseStream.Position % 0x210);
                var size = Program.GetSmallest(pageOffset, count);
                read = BaseStream.Read(buffer, offset, size);
                offset += size;
                if(size == pageOffset)
                    BaseStream.Seek(0x10, SeekOrigin.Current);
            }
            while(read < count) {
                var size = Program.GetSmallest(0x200, count - read);
                read += BaseStream.Read(buffer, offset, size);
                offset += size;
                if(size == 0x200)
                    BaseStream.Seek(0x10, SeekOrigin.Current);
            }
            return read;
        }

        public byte ReadByte() {
            var buf = new byte[1];
            if(Read(buf, 0, 1) == 1)
                return buf[0];
            throw new NANDReaderException(NANDReaderException.ErrorTypes.NotEnoughData);
        }

        public byte[] ReadBytes(int count) {
            var buf = new byte[count];
            if(Read(buf, 0, count) == count)
                return buf;
            throw new NANDReaderException(NANDReaderException.ErrorTypes.NotEnoughData);
        }

        

        public void Seek(long offset, SeekOrigin origin) {
            if(HasSpare)
                offset = ((offset / 0x200) * 0x210) + offset % 0x210;
            BaseStream.Seek(offset, origin);
        }
    }
}

That looks like Java. The Arduino UNO or MEGA cannot run that.

You can however rewrite this code in C++. It seems to read a file on an ?????? searching for some special code?

I will try to convert it and see if that is indeed the case. And yes it reads a nand .bin from flash memory. Or its suppose. will report back after converting.

If you know exactly what that code does you may be able to write new code with similar functionality for an Arduino.

The word "converting" seems to me to mean, for example, the process of converting a PC program from C# to a PC program in C++ or Java. But there are too many differences between a PC and an Arduino to think of "converting" the code to Arduino code.

...R

Robin2- Are you familiar with what it is I am attempting here? The code is in C# but the arduino uno takes C++. I cant find any kind of project like this to reference either. But I’ll toy with it. going to try and learn the basics here first I suppose and work up to this unless someone beats me to it

Kingadasouth96: Robin2- Are you familiar with what it is I am attempting here? The code is in C# but the arduino uno takes C++.

I don't think the problem is converting C# to C++. The big problem is transferring PC concepts to an Arduino. There is a huge difference between a PC and an Arduino. For example your C# code starts with

using System;
using System.IO;
using x360Utils.NAND;

There won't be any direct equivalents for those in the Arduino.

You need to write down in great detail all the steps that the C# code implements and then consider whether it is possible to write Arduino code to do the same thing.

...R