IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB.NET Discussion :

probléme de fichier


Sujet :

VB.NET

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Septembre 2008
    Messages
    6
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2008
    Messages : 6
    Par défaut probléme de fichier
    Bonjour,

    Je fait une lecture d'un fichier texte par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    Dim MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser("C:\dossier\ab.txt")
            MyReader.TextFieldType = FileIO.FieldType.Delimited
            MyReader.SetDelimiters(",")
    Tout ce passe bien, j'ai meme changer l'extention des fichiers.

    Le probléme vien du fait que je n'arrive pas à modifié un fichier et je n'arrive pas, non plus, de créé un nouveau fichier.



    PS, j'utilise sa pour lire les données d'un fichier
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    While Not MyReader.EndOfData
                Try
                    Dim boucle As Integer
     
                    currentRow = MyReader.ReadFields()
                    boucle = currentRow.Length
                    Select Case currentRow.Length
                        Case 1
                            Me.TextBoxNumPlan.Text = currentRow(0)
                            Me.TextBoxDescription.Text = ""
                            Me.TextBoxIndice.Text = ""
                            Me.TextBoxDateIndice.Text = ""
                            Me.TextBoxLocalisation.Text = ""
                            Me.TextBoxUnité.Text = ""
                            Me.TextBoxEnsembleFonctionnel.Text = ""
                        Case 2
                            Me.TextBoxNumPlan.Text = currentRow(0)
                            Me.TextBoxDescription.Text = currentRow(1)
                            Me.TextBoxIndice.Text = ""
                            Me.TextBoxDateIndice.Text = ""
                            Me.TextBoxLocalisation.Text = ""
                            Me.TextBoxUnité.Text = ""
                            Me.TextBoxEnsembleFonctionnel.Text = ""
                        Case 3
                            Me.TextBoxNumPlan.Text = currentRow(0)
                            Me.TextBoxDescription.Text = currentRow(1)
                            Me.TextBoxIndice.Text = currentRow(2)
                            Me.TextBoxDateIndice.Text = ""
                            Me.TextBoxLocalisation.Text = ""
                            Me.TextBoxUnité.Text = ""
                            Me.TextBoxEnsembleFonctionnel.Text = ""
                        Case 4
                            Me.TextBoxNumPlan.Text = currentRow(0)
                            Me.TextBoxDescription.Text = currentRow(1)
                            Me.TextBoxIndice.Text = currentRow(2)
                            Me.TextBoxDateIndice.Text = currentRow(3)
                            Me.TextBoxLocalisation.Text = ""
                            Me.TextBoxUnité.Text = ""
                            Me.TextBoxEnsembleFonctionnel.Text = ""
                        Case 5
                            Me.TextBoxNumPlan.Text = currentRow(0)
                            Me.TextBoxDescription.Text = currentRow(1)
                            Me.TextBoxIndice.Text = currentRow(2)
                            Me.TextBoxDateIndice.Text = currentRow(3)
                            Me.TextBoxLocalisation.Text = currentRow(4)
                            Me.TextBoxUnité.Text = ""
                            Me.TextBoxEnsembleFonctionnel.Text = ""
                        Case 6
                            Me.TextBoxNumPlan.Text = currentRow(0)
                            Me.TextBoxDescription.Text = currentRow(1)
                            Me.TextBoxIndice.Text = currentRow(2)
                            Me.TextBoxDateIndice.Text = currentRow(3)
                            Me.TextBoxLocalisation.Text = currentRow(4)
                            Me.TextBoxUnité.Text = currentRow(5)
                            Me.TextBoxEnsembleFonctionnel.Text = ""
                        Case 7 To 999
                            Me.TextBoxNumPlan.Text = currentRow(0)
                            Me.TextBoxDescription.Text = currentRow(1)
                            Me.TextBoxIndice.Text = currentRow(2)
                            Me.TextBoxDateIndice.Text = currentRow(3)
                            Me.TextBoxLocalisation.Text = currentRow(4)
                            Me.TextBoxUnité.Text = currentRow(5)
                            Me.TextBoxEnsembleFonctionnel.Text = currentRow(6)
                    End Select
     
     
                Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
                    MsgBox("Line " & ex.Message & "is not valid and will be skipped.")
                End Try
    End While
    je pence que Select case est nul d'un point de vue programmation

    (j'ai fait sa pour filter les fichier mal au point, ou les fichier ou ils manque des données)

  2. #2
    Membre régulier
    Profil pro
    Inscrit en
    Septembre 2008
    Messages
    6
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2008
    Messages : 6
    Par défaut
    quand on cherche on trouve :p


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
       Private Sub ButtonAnnuler_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonAnnuler.Click
            Me.Close()
        End Sub
     
        Private Sub ButtonOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOK.Click
     
     
            Dim texte As String
            texte = Me.TextBoxNumPlan.Text & "," & _
            Me.TextBoxDescription.Text & "," & _
            Me.TextBoxIndice.Text & "," & _
            Me.TextBoxDateIndice.Text & "," & _
            Me.TextBoxLocalisation.Text & "," & _
            Me.TextBoxUnité.Text & "," & _
            Me.TextBoxEnsembleFonctionnel.Text
     
            chemin = My.Settings.Default.Repertoire & "\" & Me.TextBoxNumPlan.Text & ".ldp"
            My.Computer.FileSystem.WriteAllText(chemin, texte, True)
     
            ' Nettoyage dans les textbox des valeurs lies au n° de plan.
            Form1.TextBoxNumPlan.Text = ""
            Form1.TextBoxDescription.Text = ""
            Form1.TextBoxIndice.Text = ""
            Form1.TextBoxDateIndice.Text = ""
            Form1.TextBoxUnité.Text = ""
            Form1.TextBoxLocalisation.Text = ""
            Form1.TextBoxEnsembleFonctionnel.Text = ""
     
            LectureFichierDansLeRepertoire()
            Me.Close()
     
        End Sub
     
        Private Sub ButtonAppliquer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonAppliquer.Click
            Dim texte As String
            texte = Me.TextBoxNumPlan.Text & "," & _
            Me.TextBoxDescription.Text & "," & _
            Me.TextBoxIndice.Text & "," & _
            Me.TextBoxDateIndice.Text & "," & _
            Me.TextBoxLocalisation.Text & "," & _
            Me.TextBoxUnité.Text & "," & _
            Me.TextBoxEnsembleFonctionnel.Text
     
            chemin = My.Settings.Default.Repertoire & "\" & Me.TextBoxNumPlan.Text & ".ldp"
            My.Computer.FileSystem.WriteAllText(chemin, texte, True)
     
            ' Nettoyage dans les textbox des valeurs lies au n° de plan.
            Form1.TextBoxNumPlan.Text = ""
            Form1.TextBoxDescription.Text = ""
            Form1.TextBoxIndice.Text = ""
            Form1.TextBoxDateIndice.Text = ""
            Form1.TextBoxUnité.Text = ""
            Form1.TextBoxLocalisation.Text = ""
            Form1.TextBoxEnsembleFonctionnel.Text = ""
     
            LectureFichierDansLeRepertoire()
        End Sub

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Delphi 3] Problème avec fichier ressource .RES
    Par delphim dans le forum EDI
    Réponses: 2
    Dernier message: 28/06/2005, 18h11
  2. [Servlet] Probléme écriture fichier
    Par hedgehog dans le forum Servlets/JSP
    Réponses: 4
    Dernier message: 23/05/2005, 15h17
  3. Problème lecture fichier en C++
    Par cali1983 dans le forum C++
    Réponses: 17
    Dernier message: 20/05/2005, 09h36
  4. Problème ouverture fichier par double clic...
    Par sankookai dans le forum MFC
    Réponses: 4
    Dernier message: 11/05/2005, 09h13
  5. Problème avec fichier texte
    Par jpdelx dans le forum ASP
    Réponses: 7
    Dernier message: 13/11/2003, 13h17

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo