5 Replies - 698 Views - Last Post: 27 June 2015 - 11:46 AM Rate Topic: -----

#1 Dreamfall   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 137
  • Joined: 26-January 15

Display in textbox only certain subfolders...

Posted 24 June 2015 - 03:37 PM

How do I view in a textbox through "SaveFileDialog" only the path of the folders contained within the folder of the executable... :helpsmilie:/>

I tried in this world, but if you change the folder location, in any other part in the computer, it also changes the path in the textbox... :nottalkingtoyou:/>

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Console.Beep()
        Using Open_Path As New SaveFileDialog()
            Open_Path.InitialDirectory = Application.StartupPath
            Open_Path.Filter = "Executable File|*.exe;"
            Dim Result As DialogResult = Open_Path.ShowDialog()
            If Result = DialogResult.OK Then
                Console.Beep()
                TextBox1.Text = Open_Path.FileName
                Dim FullDir As String = Path.GetDirectoryName(TextBox1.Text)
                Dim IndexDir1 As String = FullDir.Substring(FullDir.IndexOf("\") + 1)
                Dim IndexDir2 As String = IndexDir1.Substring(IndexDir1.IndexOf("\") + 1)
                Dim IndexDir3 As String = IndexDir2.Substring(IndexDir2.IndexOf("\") + 1)
                Dim IndexDir4 As String = IndexDir3.Substring(IndexDir3.IndexOf("\") + 1)
                Dim IndexDir5 As String = IndexDir4.Substring(IndexDir4.IndexOf("\") + 1)
                Dim IndexDir6 As String = IndexDir5.Substring(IndexDir5.IndexOf("\") + 1)
                Dim IndexDir7 As String = IndexDir6.Substring(IndexDir6.IndexOf("\") + 1)
                Dim IndexDir8 As String = IndexDir7.Substring(IndexDir7.IndexOf("\") + 1)
                DirectX.Text = IndexDir8 + "\" + Path.GetFileName(TextBox1.Text)
            Else
                Beep()
                Exit Sub
            End If
        End Using
    End Sub


This post has been edited by Dreamfall: 24 June 2015 - 03:39 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Display in textbox only certain subfolders...

#2 Martyr2   User is offline

  • Programming Theoretician
  • member icon

Reputation: 5226
  • View blog
  • Posts: 14,008
  • Joined: 18-April 07

Re: Display in textbox only certain subfolders...

Posted 24 June 2015 - 04:12 PM

I am not sure I fully understand what you are asking. You have the initialdirectory property set, so when you open the file dialog you should be seeing the contents of the folder of your Application.StartupPath. Now if you go and change that folder through the box, of course it will change the textbox at the same time. This is the same behavior you see with Windows Explorer. The idea is that you will change the location first, then specify your file in the textbox below.

If this is not what you are talking about, can you please clarify more? Thanks. :)
Was This Post Helpful? 0
  • +
  • -

#3 Dreamfall   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 137
  • Joined: 26-January 15

Re: Display in textbox only certain subfolders...

Posted 25 June 2015 - 12:31 AM

When loading the directory path within the folder of the executable application, I visualize this full path in textbox :"C:\Users\MyName\Desktop\Inside_Executable\SubFolder1\SubFolder2\File.exe"

But I would like to view only the path of the subfolders inside the folder of the executable this:"SubFolder1\SubFolder2\File.exe" :online2long:/>

In short, start reading the path, only in the application folder... :helpsmilie:/>
Was This Post Helpful? 0
  • +
  • -

#4 Dreamfall   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 137
  • Joined: 26-January 15

Re: Display in textbox only certain subfolders...

Posted 25 June 2015 - 01:47 PM

Guys no one who can give me some help on this problem,how do I view the complete directory path starting with from the application where they are located?? :glare:
Was This Post Helpful? 0
  • +
  • -

#5 Abdallahesam   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 26-June 15

Re: Display in textbox only certain subfolders...

Posted 27 June 2015 - 11:40 AM

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Console.Beep()
        Using Open_Path As New SaveFileDialog()
            Open_Path.InitialDirectory = Application.StartupPath
            Open_Path.Filter = "Executable File|*.exe;"
            Dim Result As DialogResult = Open_Path.ShowDialog()
            If Result = DialogResult.OK Then
                Console.Beep()
                Dim Inf As FileInfo = New FileInfo(Open_Path.FileName)
                If Inf.Directory.FullName <> Application.StartupPath Then GoTo El
                TextBox1.Text = Inf.FullName
                DirectX.Text = Inf.Directory.Name & "\" & Inf.Name
            Else
El:             Beep()
                Exit Sub
            End If
        End Using
    End Sub


Was This Post Helpful? 0
  • +
  • -

#6 andrewsw   User is offline

  • RequestedRangeNotSatisfiable
  • member icon

Reputation: 6552
  • View blog
  • Posts: 26,563
  • Joined: 12-December 12

Re: Display in textbox only certain subfolders...

Posted 27 June 2015 - 11:46 AM

Care to explain what that code dump is doing, and why it is useful to the OP?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1