Sign in to follow this  
Followers 0
ezzetabi

Having full path from file name...

6 posts in this topic

I am making a func that uses FileFindNextFile() for rolling files in a folder, so far so good. The parameter of this search is a full path with wildcards.

E.g. c:\hello\*.*

The result of the next FindNextFile() are without the path!

How can I have it back? I thought FileGetShortName or LongName had this function but I was wrong. I checked in the help file but I am still solution-less.

:ph34r:

Share this post


Link to post
Share on other sites



Hmmm....in my 'search'-functions I always put the path and filename independent to the FileFind....

Like:

$path = "C:\Test\"

$file = "*.*"

$search = FileFindFirstFile($path & $file)

...

Do you understand what I mean?

You can now later use the 'saved' path...

Share this post


Link to post
Share on other sites

Save the path and do $path & "\" & $file


Who else would I be?

Share this post


Link to post
Share on other sites

Thanks pals.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

If anyone can have my same problem...

($a is just an example)

Dim $a, $path, $file, $c
; $a is the starting point. It may be a full path or just a filename.

$a = c:\temp\name.txt

   If Not StringInStr($a, "\") Then
      $path = @WorkingDir & "\"
    ;and $file = $file;-D
   Else
      For $C = StringLen($a) To 1 Step - 1
         If StringMid($a, $C, 1) = "\" Then
            $PATH = StringLeft($a, $C)
            $FILE = StringTrimLeft($a, $C)
            ExitLoop
         EndIf
      Next
   EndIf

MsgBox(0,"",$path & "       " & $file)

Edit: Improved code.

Edited by ezzetabi

Share this post


Link to post
Share on other sites

I agree with the others, it's typically easier to save the path in a separate array for later use. However you can also use the @WorkingDir macro to obtain the name of the current working directory.

If you only have access to the full filename, along with path (ie: [full path]\[filename].[ext]) then you can use the StringSplit function to make it easy to separate the file name and path.

Several months ago, I posted an example of how to search the entire computer for a specified file. The code is very slow but it could be optimized for your needs. Feel free to check out this post, if you're curious.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0