Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
260 views
in Technique[技术] by (71.8m points)

vb.net - How can I use settings from another form in project to populate file directory to list exe files

Apologies in advance this is my first project.

I am creating a VB project and have created a settings(FormSettings.vb) page where the user browses to their steam library and that inputs into a text box(Textbox1.Text) and got it to save etc. On myy main form of the project I have a drop down box that I want to populate all the exe files which works ok when i specify the directory in the code but what I want it to do it pull the directory path from the users setting

Working

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    Dim directory = "D:Steam Library"
    Dim files() As System.IO.FileInfo
    Dim dirinfo As New System.IO.DirectoryInfo(directory)
    files = dirinfo.GetFiles("*.exe", IO.SearchOption.AllDirectories)
    For Each file In files
        cmbSelectGame.Items.Add(file)
    Next

End Sub'''

I have also tried

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    Dim directory = FormSettings.Textbox1.Text
    Dim files() As System.IO.FileInfo
    Dim dirinfo As New System.IO.DirectoryInfo(directory)
    files = dirinfo.GetFiles("*.exe", IO.SearchOption.AllDirectories)
    For Each file In files
        cmbSelectGame.Items.Add(file)
    Next

End Sub

Any guidance is appreciated and thank you in advance

question from:https://stackoverflow.com/questions/65870437/how-can-i-use-settings-from-another-form-in-project-to-populate-file-directory-t

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...