修改文件夾下所有文件并保存-創(chuàng)新互聯(lián)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.IO.IsolatedStorage;
using System.Text;
using System.Text.RegularExpressions;
namespace 更改文件名
{
    class Program
    {
         
       static void Main(string[] args)
        {
            string path = @"D:\Web";
            DirectoryInfo TheFolder = new DirectoryInfo(path);
            string txt="";
            foreach (FileInfo item in TheFolder.GetFiles())
            {
                string name = item.Name;
                string[] houzhui = name.Split('.');
                string readtxt;
                bool pp = false;
                if (houzhui.Count()==2)
                {
                    using (StreamReader sr=new StreamReader(path+"\\"+item.Name,Encoding.UTF8))
                    {
                        readtxt = sr.ReadToEnd();
                        string pattern = @"inherits=\W\S*, \w*\W";
                        string inherits;
                       
                        foreach (Match match in Regex.Matches(readtxt, pattern))
                        {
                            pp = true;
                            string inher = match.Value.Substring(10,match.Value.LastIndexOf('"')-10);
                            inherits = "Inherits=" + '"' + inher.Split(',')[0] + '"' + " CodeBehind="+'"'+item.Name+".cs"+'"';
                          txt= readtxt.Replace(match.Value,inherits);
                        }
                      
                    }
                    if (pp)
                    {
                        using (StreamWriter sw = new StreamWriter(path + "\\" + item.Name))
                        {
                            sw.Write(txt);
                        }
                    }
                    
                }
                else
                {
                     
                }
            }
        }
    }
}

創(chuàng)新互聯(lián)www.cdcxhl.cn,專業(yè)提供香港、美國(guó)云服務(wù)器,動(dòng)態(tài)BGP最優(yōu)骨干路由自動(dòng)選擇,持續(xù)穩(wěn)定高效的網(wǎng)絡(luò)助力業(yè)務(wù)部署。公司持有工信部辦法的idc、isp許可證, 機(jī)房獨(dú)有T級(jí)流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確進(jìn)行流量調(diào)度,確保服務(wù)器高可用性。佳節(jié)活動(dòng)現(xiàn)已開啟,新人活動(dòng)云服務(wù)器買多久送多久。

創(chuàng)新互聯(lián)秉承實(shí)現(xiàn)全網(wǎng)價(jià)值營(yíng)銷的理念,以專業(yè)定制企業(yè)官網(wǎng),做網(wǎng)站、成都網(wǎng)站制作,微信平臺(tái)小程序開發(fā),網(wǎng)頁(yè)設(shè)計(jì)制作,移動(dòng)網(wǎng)站建設(shè),全網(wǎng)營(yíng)銷推廣幫助傳統(tǒng)企業(yè)實(shí)現(xiàn)“互聯(lián)網(wǎng)+”轉(zhuǎn)型升級(jí)專業(yè)定制企業(yè)官網(wǎng),公司注重人才、技術(shù)和管理,匯聚了一批優(yōu)秀的互聯(lián)網(wǎng)技術(shù)人才,對(duì)客戶都以感恩的心態(tài)奉獻(xiàn)自己的專業(yè)和所長(zhǎng)。

當(dāng)前名稱:修改文件夾下所有文件并保存-創(chuàng)新互聯(lián)
文章轉(zhuǎn)載:http://bm7419.com/article10/gohdo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供建站公司、自適應(yīng)網(wǎng)站、網(wǎng)站導(dǎo)航用戶體驗(yàn)、網(wǎng)站維護(hù)全網(wǎng)營(yíng)銷推廣

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)