Results 1 to 5 of 5

Thread: [RESOLVED] Exploring directories

  1. #1

    Thread Starter
    Addicted Member Fonty's Avatar
    Join Date
    May 2006
    Location
    New York
    Posts
    173

    Resolved [RESOLVED] Exploring directories

    I'd like to be able to depend only in the hierarchy of the directories of my project files and no in which computer, unit or server the whole project is located.
    For most of the file paths I use Application.CurrentProject.Path (in this case for Access).
    Suppose your file lies in directory H:\XXX\YYY\ZZZ
    But in H:\XXX\ you have either:
    1. H:\XXX\YYY, and
    2. H:\XXX\RRR

    Is it possible to get the current directory string, go up two directories and then just add to this string "RRR" so that you are now in H:\XXX\RRR?
    This should be possible by manipulating the string and searchin character \.. but is there some other way to programm this?
    Last edited by Fonty; May 9th, 2007 at 11:11 AM.

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Exploring directories

    Hi

    One way I can think of is using the mid function to check for "\" and then adding the "RRR"

    for example

    vb Code:
    1. Private Sub CommandButton1_Click()
    2.    
    3. Strg = "H:\XXX\YYY\ZZZ"
    4. Count = 0
    5.  
    6. For i = 1 To Len(Strg)
    7.  
    8. If Mid(Strg, i, 1) = "\" Then
    9.  
    10.     temp = Mid(Strg, 1, i - 1)
    11.     Count = Count + 1
    12.     If Count = 2 Then Exit For
    13.  
    14. End If
    15.  
    16. Next i
    17.  
    18. strg2 = temp & "\RRR"
    19.  
    20. MsgBox strg2  '<==== this will give you "H:\XXX\RRR"
    21.  
    22. End Sub

    Hope this helps...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  3. #3
    Member
    Join Date
    Mar 2007
    Posts
    32

    Re: Exploring directories

    One way you can do this is to make an array of strings and then join them to make your new path

    Dim temp(2) as string
    temp(0)="H:\"
    temp(1)="XXX\"
    temp(2)=Name
    temp(3)=".xls"
    newstring=join(temp, "")
    now newstring will now equal H:\XXX\Name.xls
    therefore, you just change out your second value in the array, temp(2) and rejoin

  4. #4
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Exploring directories

    Hi Brellis

    just a thought...

    how will you decide what value does temp(1) hold during runtime...

    Right now we are just taking a fixed string as

    Strg = "H:\XXX\YYY\ZZZ"

    It will be simple to store the path in Strg during runtime in the code which I provided...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  5. #5
    Member
    Join Date
    Mar 2007
    Posts
    32

    Re: Exploring directories

    my bad, i thought Fonty already had the path. If he is getting the path on the fly I'd use your method, or do what I was talking about and I'd use the split command

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width