[VB.net] Pb d'ecriture dans un fichier.
Bonjour,
j'ai un petit soucis avec le code ci dessous. Si mon fichier n'existe pas je le crée mais des que je tente d'ecrire quelque chose dedans j'ai le message suivant
Message "The process cannot access the file 'C:\mulu.csv' because it is being used by another process."
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| Try
'Test si le fichier existe
If Not File.Exists(FileName.NomFichierComplet) Then
File.Create(FileName.NomFichierComplet)
Header = FileName.NomFichier & vbCrLf
Header = Header & Format(Now, "dd-mm-yyyy").ToString & vbCrLf
newFile = True
End If
Sw = New StreamWriter(FileName.NomFichierComplet, True)
If newFile Then Sw.WriteLine(Header)
Dim NumBit As Integer = AdrBase
Dim BitValue As Byte = 0
For i As Integer = 0 To DataBits.Length - 1
BitValue = DataBits(i)
For BitPos As Integer = 0 To 7
LigneCSV = "%M" & NumBit & ";" & Str(BitValue And 1)
BitValue = BitValue >> 1
Sw.WriteLine(LigneCSV)
NumBit = NumBit + 1
If NumBit >= NbrBits Then Exit For
Next
Next
Catch ex As Exception
'Gestion des erreurs
Finally
Sw.Close()
End Try |
je pense que ce probleme est connu , mais je trouve pas la solution
Pouvez me dire ou trouver la solution ?
@+ Vijeo