Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Changing attribute on a file
Message
De
27/09/2004 07:12:06
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00946210
Message ID:
00946211
Vues:
18
Hei Kjell,

with WINAPI:
#DEFINE FILE_ATTRIBUTE_READONLY 	0x01
#DEFINE FILE_ATTRIBUTE_HIDDEN		0x02
#DEFINE FILE_ATTRIBUTE_SYSTEM		0x04
#DEFINE FILE_ATTRIBUTE_DIRECTORY	0x10
#DEFINE FILE_ATTRIBUTE_ARCHIVE		0x20
#DEFINE FILE_ATTRIBUTE_NORMAL		0x80
#DEFINE FILE_ATTRIBUTE_TEMPORARY	0x0100

declare Integer GetFileAttributes in win32api string @
declare Integer SetFileAttributes in win32api string @, Integer

function FileResetReadOnly(FileName)
	local fa
	fa = GetFileAttributes(@FileName)

	if( fa == -1 )
		return .F.
	endif

	if( empty(bitand(fa, FILE_ATTRIBUTE_READONLY)) ) && file was not readonly
		return .F.
	endif

	fa = bitand(fa, bitnot(FILE_ATTRIBUTE_READONLY))

	if( empty(SetFileAttributes(@FileName, fa)) )
		return .F.
	endif

endfunc
With WSH:
#define READONLY 1
#define HIDDEN 2
#define SYSTEM 4
#define ARCHIVE 32
oFSO = CreateObject("Scripting.FileSystemObject")
oFile = oFSO.GetFile("c:\xyz.doc")
oFile.Attributes = READONLY && changes to RO
>Hallo
>I have searched through the whole helpsystem in VFP7, but I cant find what Im looking for:
>How do I change the attribute from "read/write" to "read-only" to a file on the disc whith a command in VFP?
>
>Thankyou
>/Kjell
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform