因為需要將一個資料夾中的txt由亂碼的狀態轉為Utf-8的XML檔

所以把這寫在一起

Dim filePath As String = Server.MapPath(doc + Me.ddlFolder1.SelectedValue + “\”)
        Dim dirInfo As New DirectoryInfo(filePath)
        Dim fileInfos() As FileInfo = dirInfo.GetFiles(”*.txt”)
        Dim file As String = Me.ddlFolder2.SelectedValue

        For Each f As FileInfo In fileInfos
            Dim filename As String = f.Name
            Dim lst As String() = filename.Split(”.”)
            Dim strfile As String = lst(0)
            Dim strFromPath As String = Server.MapPath(”..\\Data\\TaichungCounty\\”)
            Dim strToPath As String = Server.MapPath(”..\\Data\\XML\\”)
            Dim strCon As New StreamReader(strFromPath + strfile + “.txt”, System.Text.Encoding.Default)
            Dim s As String = strCon.ReadToEnd()
            Dim sWriter As New StreamWriter(strToPath + strfile + “.xml”, False, System.Text.Encoding.UTF8)
            sWriter.Write(s)
            sWriter.Close()
        Next

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 包爾伯 的頭像
    包爾伯

    人生過程精彩才是重點

    包爾伯 發表在 痞客邦 留言(0) 人氣()