Sign in to follow this  
Followers 0
DarkNecromancer

removable drive problems

5 posts in this topic

i'm creating a program that will be able to check the date modified between my home school and the drive itself. Any variances will copy the file to the drive easy enough. But i've been stuck for a while with a problem. Whenever i check the attributes of the files to check for directories the results are always blank. i added the bit in th example to check for errors

If @error Then
    MsgBox(4096,"Error", "Could not obtain attributes.")
    Exit
Else
    If StringInStr($attrib, "R") Then
    MsgBox(4096,"", "File is read-only.")
    EndIf
EndIf
but it returns no errors. So i displayed the attributes and neither file nor directory return any attributes. This is off the removable drive that its reading. I was wondering if anyone had any ideas :idiot:

~Dark

Share this post


Link to post
Share on other sites

Try the following--changing G:\filename.txt to something appropriate, of course, and report the results:

$file = "G:\filename.txt"

If Not FileExists($file) Then MsgBox(4096,"Error","File does not exist!")

$attrib = FileGetAttrib($file)
MsgBox(4096, "Err: " & @error, "Attributes:" & $attrib)

The above seems to work for me with latest beta of AutoIt on WinXP Pro SP2 with a USB Flash Drive.


Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

ok i ran that and the directories returned d and all the other files returned a. So i dont know whats wrong with my code so i'll include the first part. I'll only post this for now because it isn't even getting past this.

$search = FileFindFirstFile($drives[$i] & "\School\*.*")  

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
    $fileattrib = FileGetAttrib ( $file )
    msgbox(0, $file, $fileattrib)
    
    If @error Then
        MsgBox(4096,"Error", "Could not obtain attributes.")
        Exit
    Else
        If StringInStr($fileattrib, "R") Then
            MsgBox(4096,"", "File is read-only.")
        EndIf
    EndIf

    $attrib = StringInStr ( $fileattrib, "D" , 0 )
    If $attrib <> 0 Then
        $d = $d + 1
        $dirarray[$d] = $file
    else
        $y = $y + 1
        $filearray[$y] = $file
    EndIf
WEnd

kinda an odd fact. When i have it tell me the attribute it finds, for . and .. it returnes D :D . why those 2 and not any of the others. :idiot:

Edited by DarkNecromancer

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Upon brief inspection, I believe FileFindNextFile only returns the file name without the full path!

Try $fileattrib = FileGetAttrib ( $drives[$i] & "\School\" & $file ) to see if that helps. I'd verify that the output of FileFindNextFile is what you expect it to be, because FileGetAttrib only works with correct file names :idiot:

Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

ahhh that did the trick thanks a bunch CyberSlug

~Dark

Edited by DarkNecromancer

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