Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

Save and Edit some Strings from loaded line to Text! (StreamReader)

$
0
0

[Please move this thread to it's right place ( C# )]

Hi, I have tried lots of codes posted here.. and another places..

It doesn't do what want to do.

First See the code : 

Load Button :

private void LoadBtn_Click(object sender, EventArgs e)
        {
            TextReader testTxt = new StreamReader(ItemBaseInfosPath);

            
            string read; 
            do  
            {
                read = testTxt.ReadLine();

                if (read.Contains(IDTxt.Text))
                {
                    
                    ConquerItemBaseInformation CIBI = new ConquerItemBaseInformation();
                    CIBI.Parse(read);
                    NameTxt.Text = CIBI.Name;
                    LevelTxt.Text = Convert.ToString(CIBI.Level);
                    MaxAttackTxt.Text = Convert.ToString(CIBI.MaxAttack);
                    MinAttackTxt.Text = Convert.ToString(CIBI.MinAttack);
                    PhysicalTxt.Text = Convert.ToString(CIBI.PhysicalDefence);
                    DodgeTxt.Text = Convert.ToString(CIBI.Dodge);
                    MagicAttackTxt.Text = Convert.ToString(CIBI.MagicAttack);
                    MagicDefTxt.Text = Convert.ToString(CIBI.MagicDefence);
                    AttackRangeTxt.Text = Convert.ToString(CIBI.AttackRange);
                    PriceTxt.Text = Convert.ToString(CIBI.ConquerPointsWorth);
                    break;
                }
                else
                {
                    MessageBox.Show("Item Not Found.");
                }
            } while (read != null);

Save Button :

private void SaveBtn_Click(object sender, EventArgs e)
        {
            TextReader testTxt = new StreamReader(ItemBaseInfosPath);
            string read, read1, read2, read3, read4, read5, read6,
                read7, read8, read9, read10; 
            do  
            {

                read = testTxt.ReadLine();

                if (read.Contains(IDTxt.Text))
                {              
                    
                    
                    ConquerItemBaseInformation CIBI = new ConquerItemBaseInformation();
                    CIBI.Parse(read);
                    CIBI.Name = NameTxt.Text;
                    CIBI.Level = Convert.ToByte(LevelTxt.Text);
                    CIBI.MaxAttack = Convert.ToByte(MaxAttackTxt.Text);
                    MessageBox.Show(read);
                    break;
                }

            } while (read != null);
        }

Load Button is working Great! Without problems. The problems in Save Button.

I got now the line, Example : " 111003@@IronHelmet@@21@@0@@15@@0@@0@@0@@0@@0@@0@@0@@150@@0@@0@@0@@3@@0@@0@@0@@0@@3899@@3899@@0@@0@@0@@0@@0@@0@@0@@0@@0@@1@@1000@@0@@0@@0@@0@@0@@0@@0@@0@@0@@0@@0@@0@@0@@0@@0@@0@@0@@0@@0@@Warrior`sHelmet@@None@@5@@0@@0@@0@@2020@@500@@"

111003 is the ID, IronHelmet is the Name, 15 is the level.

It loaded.. I want to save it. (Note for each of these have it's TextBox.

It's ItemEditor program, so i want when i edit anything in TextBox and Press "Save button"

It replace each of the edited things and save the text file again! :)

(Note : String.Replace("",""); This code if i use it and the textbox that should edit, if it's value (Text) is 0 then it will change All Values of 0 in the Line! = Fail )

I hope you understand me! :)

Thanks!




Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>