Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check for Read Only File 1

Status
Not open for further replies.

jimoo

Programmer
Jun 2, 2003
1,111
US
Does anyone have a snippet of code that can return if a file attribute is set to read only.

I have a process that needs to copy files, but only if the file attribute is not set to read-only.

Thanks in advance.

Jim Osieczonek
Delta Business Group, LLC
 
Hi Jim,

Something like this (not tested):

Code:
oFS = CREATEOBJECT("Scripting.FileSystemObject")
oFile = oFS.GetFile("c:\data\somefile.txt")
IF BITAND(oFile.Attributes, 1) = 1
  * File is read-only
ELSE
  * File is read-write
ENDIF

Give it a try and let us know if it works.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Thanks Mike

I also remembered how to do it with the ADIR function. How quickly we forget when we do not use it.


DECL Aboo
lnCount = ADIR('aboo','C:\MyDir\*.*')

It is the 5th item in the array list.




Jim Osieczonek
Delta Business Group, LLC
 
 
Mike, it turns out I was getting inconsistent results using the ADIR().

The flag combinations were sometimes different.

Your solution provided fast / consistent results

Thanks again


Jim Osieczonek
Delta Business Group, LLC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top