How would i create Save button for this ?

Coder123 Jan 22, 2012

  1. Coder123

    Coder123 Finnish Modder XPG Developer TeamXPG
    45/47

    Joined:
    Jan 21, 2012
    Messages:
    1,953
    Likes Received:
    717
    Trophy Points:
    105
    Gender:
    Male
    Location:
    Finland
    Console:
    Xbox
    Here is the code FULL code:

    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;
    namespace csharp
    {
        public partial class Form1 : Form
        {
    	    public Form1()
    	    {
    		    InitializeComponent();
    	    }
    	    private void button1_Click(object sender, EventArgs e)
    	    {
    		    OpenFileDialog ofd = new OpenFileDialog();
    		    ofd.Title = "Open profile/gamesave";
    		    if (ofd.ShowDialog() == DialogResult.OK)
    		    {
    			    BinaryReader br = new BinaryReader(File.Open(ofd.FileName, FileMode.Open));
    			    br.BaseStream.Position = 0x0; 
    			    textBox1.Text = ToASCII(br.ReadBytes(4));
    			    br.BaseStream.Position = 0x360; 
    			    textBox2.Text = ToHex(br.ReadBytes(8));
    			    br.BaseStream.Position = 0x371; 
    			    textBox3.Text = ToHex(br.ReadBytes(8));
    			    br.BaseStream.Position = 0x3FD; 
    			    textBox4.Text = ToHex(br.ReadBytes(14));
    			    br.BaseStream.Position = 0x36C; 
    			    textBox5.Text = ToHex(br.ReadBytes(5));
    			    br.BaseStream.Position = 0x412; 
    			    textBox6.Text = ToUnicode(br.ReadBytes(40));
    			    br.BaseStream.Position = 0x1692; 
    			    textBox7.Text = ToUnicode(br.ReadBytes(70));
    			    br.BaseStream.Position = 0x20; 
    			    textBox8.Text = ToASCII(br.ReadBytes(8));
    			    br.BaseStream.Position = 0x1F; 
    			    textBox9.Text = ToHex(br.ReadBytes(1));
    			    br.BaseStream.Position = 0x0; 
    			    textBox10.Text = ToHex(br.ReadBytes(8));
    			    br.BaseStream.Position = 0xC140; 
    			    textBox11.Text = ToASCII(br.ReadBytes(12));
    			    br.BaseStream.Position = 0x1C2A1; 
    			    textBox12.Text = ToUnicode(br.ReadBytes(44));
    			    MessageBox.Show("File Succesfully Loaded", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
    
    			    br.Close();
    			   
    
    		    }
    	    }
    	    private string ToHex(byte[] buf)
    	    {
    		    return BitConverter.ToString(buf).Replace("-", "");
    	    }
    	    private string ToASCII(byte[] buf)
    	    {
    		    return Encoding.ASCII.GetString(buf);
    	    }
    	    private string ToUnicode(byte[] buf)
    	    {
    		    return Encoding.Unicode.GetString(buf);
    	    }
    	    private void button2_Click(object sender, EventArgs e)
    	    {
    	    }
    
        }
    }
    

    So i would want button2_click to save all changes what are made to the values.

    Thanks !
     
  2. c0

    c0madr0ne Member
    45/47

    Joined:
    Jul 19, 2009
    Messages:
    895
    Likes Received:
    109
    Trophy Points:
    45
    Console:
    Playstation 3
    just do the opposite of your reader.


    BinaryReader br = new BinaryWriter(File.Open(ofd.FileName, FileMode.Open));
    br.BaseStream.Position = 0x0;
    br.Write(textboxshit)

     

Share This Page

Close