Problem changing file and dir attributes
Posted: Tue Dec 07, 2004 4:29 pm
Hello,
i've got a problem:
I've a program that copy files from CDROM to hd, files and dir are then with read only attribute set.
When copied on hd, i run my prog that change files and dir attributes to nothing so one can read and write to them.
The code works ok on w98se, but not on xp: files are always set to normal, ok
but dirs don't whant to be set on normal at all ! (only on xp).
here is the code i retrieved on this forum:
Could someone with xp help me with that code !
Thank's a lot.
Dominique
i've got a problem:
I've a program that copy files from CDROM to hd, files and dir are then with read only attribute set.
When copied on hd, i run my prog that change files and dir attributes to nothing so one can read and write to them.
The code works ok on w98se, but not on xp: files are always set to normal, ok
but dirs don't whant to be set on normal at all ! (only on xp).
here is the code i retrieved on this forum:
Code: Select all
; 07/12/2004: mise au point de la procédure de modification d'attributs (répertoires et fichiers).
; Les fonctions de Windev échouent: si le rep ne contient aucun fichier, il n'est pas parcouru
; et son attribut ne peut être changé !
; Reste à trouver pourquoi cela ne fonctionne pas sous XP, pour les rep ! (l'attribut reste inchangé)
Procedure GetList(SourceDirectory$, Start)
If ExamineDirectory(Start, SourceDirectory$, "*.*")
SetFileAttributes_(SourceDirectory$, #FILE_ATTRIBUTE_NORMAL) ; Threaded search start
Repeat ; Repeat all the following
Type = NextDirectoryEntry() ; Set file or directory to start
If Type = 2
If DirectoryEntryName() <> "." And DirectoryEntryName() <> ".."
a$ = SourceDirectory$ + DirectoryEntryName()
Debug "Dir avant: " + a$
trer = SetFileAttributes_(a$, #FILE_ATTRIBUTE_NORMAL)
a$ + "\"
Debug "Dir après: " + a$ + " Résultat: " + Str(trer)
GetList(a$, Start + 1)
UseDirectory(Start)
EndIf
Else
If Type = 1
Place$ = SourceDirectory$ + DirectoryEntryName()
; Add the filename and directory
rest = SetFileAttributes_(Place$, #FILE_ATTRIBUTE_NORMAL)
Debug "File: " + Place$ + " Résultat: " + Str(rest)
EndIf
EndIf
Until Type = 0
EndIf
EndProcedure
b.s = PathRequester("Choisissez un répertoire et appuyez sur entrée", "")
If b <> ""
GetList(b, 0)
MessageRequester("Info", "")
EndIf
Thank's a lot.
Dominique