0
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace AnchorChanger
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void dosyalar_Click(object sender, EventArgs e)
        {
            txtdosyalar.Text = "";
            int dosyasayisi = 0;
            openFileDialog1.Multiselect = true;
            openFileDialog1.ShowDialog();
            foreach (string str in openFileDialog1.FileNames)
            {
                txtdosyalar.Text += str + "\r\n";
                dosyasayisi += 1;
            }
            txtdosyalar.Text += "Total " + dosyasayisi + " file will be process";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int islemsay = 0;
            foreach (var str in openFileDialog1.FileNames)
            {
                string isle = File.ReadAllText(str);
                File.WriteAllText(str, isle);
                islemsay = islemsay + 1;
                for (int i = 0; i < 500; i++)
                {
                    string si = i.ToString();
                    string degistirilen = "<a href=\"#_ftn"+si+"\" name=\"_ftnref"+si+"\" title=\"\" id=\"_ftnref"+si+"\">";
                    string degisim = "<a href=\"#_ftn"+si+"\" name=\"_ftnref"+si+"\" title=\"\" id=\"_ftnref"+si+"\"><SUP>"+si+"</SUP>";
                    File.WriteAllText(str, isle.Replace(degistirilen, degisim));
                }
            };

            txtdeisim.Text += islemsay + " file processed" + "\r\n";
        }



    }
}

Problem is simple. I have a project that I have to set tousand of anchor in html. So I want to change it and set numbers to anchors. Program will be change this. Program not compare integer i with string str. I tried with using string si = i.ToString(); but not worked.

For example this
<a href="#_ftn3" name="_ftnref3" title="" id="_ftnref3">

Will be change like this :
<a href="#_ftn3" name="_ftnref3" title="" id="_ftnref3"><SUP>3</SUP>

I tried to use regex but not worked or I couldn't. I'm waiting your help. Thank you

Gokhan Alp
  • 61
  • 5

0 Answers0