因為需要將一個資料夾中的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
留言列表