Alternative Openfiledialog

Résolu
julia Namor Messages postés 524 Date d'inscription jeudi 27 mars 2014 Statut Membre Dernière intervention 13 janvier 2024 - 26 nov. 2023 à 09:26
Whismeril Messages postés 19036 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 2 mai 2024 - 28 nov. 2023 à 22:52

Bonjour

je bloque depuis hier , sur ce code qui ouvre via openfiledialog  un dataset stocké dans un dossier .

Je voudrais sauter l'étape du openfiledialog et ouvrir directement le dataset dont le chemin d’accès est :

Dim Filename As String = System.IO.Path.GetFileName(My.Application.Info.DirectoryPath & "\" & "\stocks" & "\" & "Classeur.xml")

voila le code :

Private Sub MenuOuvrirDS_Click(sender As Object, e As EventArgs) Handles MenuOuvrirDS.Click, BoutonDS.Click
        Dim Premier As Boolean = My.Settings.premier
        If Premier = False Then

            For Each Table In My.Forms.Affichage.DSet.Tables
                Table.dispose
            Next Table


        End If
        Dim DialogueOuvrir As New OpenFileDialog
        With DialogueOuvrir
            .InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments
            .Filter = "Fichiers xml (*.xml)|*.xml"
            .ShowDialog()
        End With
        Dim fichierDS As String = DialogueOuvrir.FileName
        My.Settings.fichierDS = fichierDS
        Dim fichierschéma As String = Path.ChangeExtension(fichierDS, "xsd")
        My.Settings.LeSchema = fichierschéma

        With My.Forms.Affichage
            .DSet.ReadXmlSchema(fichierschéma)
            .DSet.ReadXml(fichierDS)
            .DataGridView1.DataSource = .DSet.Tables("Initiale")
            .MdiParent = Me
            .Show()
        End With
        My.Settings.premier = False

    End Sub

PS: merci à Clément Marmotte pour la mise a disposition de ce programme.

le lien du programme : https://www.transfernow.net/dl/20231126yj8LcCJG

merci beaucoup de votre aide


Windows / Firefox 120.0

A voir également:

2 réponses

Whismeril Messages postés 19036 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 2 mai 2024 931
26 nov. 2023 à 11:05

Bonjour

tu supprimes

        Dim DialogueOuvrir As New OpenFileDialog
        With DialogueOuvrir
            .InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments
            .Filter = "Fichiers xml (*.xml)|*.xml"
            .ShowDialog()
        End With
        Dim fichierDS As String = DialogueOuvrir.FileName
        My.Settings.fichierDS = fichierDS

Et tu mets

Dim fichierDS As String = My.Settings.fichierDS

0
Whismeril Messages postés 19036 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 2 mai 2024 931
26 nov. 2023 à 11:06

Ha non, tu mets ton chemin de fichier

0
julia Namor Messages postés 524 Date d'inscription jeudi 27 mars 2014 Statut Membre Dernière intervention 13 janvier 2024 33
27 nov. 2023 à 23:44

Super

c'est exactement ce qu'il me fallait

bien à vous

0
Whismeril Messages postés 19036 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 2 mai 2024 931
28 nov. 2023 à 22:52

De rien

pense à marquer le sujet résolu 

0