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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting file attributes

Status
Not open for further replies.

hudradgs

Programmer
Jun 6, 2001
4
GB
I have written some script which uses the file system object to move files within a server. Some of the files are Office documents which are viewed using IE5.5. The problem is when more than one person tries viewing the file it excludes the second person. The only way round it seems to be changing the file attributes to read-only. Is there any way of doing this using FSO? It would be a big benefit to only have read-only files on the server anyway.
 
Here is an example

Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(PathTofile)f.attributes and 32 Then
f.attributes = MyAttributes
FileAttributes=f.attributes


and the MyAttributes could be are:
Read/Write - u can set them
Normal - 0 Normal file. No attributes are set.
ReadOnly - 1 Read-only file. Attribute is read/write.
Hidden - 2 Hidden file. Attribute is read/write.
System - 4 System file. Attribute is read/write.
Archive - 32 File has changed since last backup. Attribute is read/write.

Read-Only - u cannot set them
Volume - 8 Disk drive volume label. Attribute is read-only.
Directory - 16 Folder or directory. Attribute is read-only.
Alias - 64 Link or shortcut. Attribute is read-only.
Compressed - 128 Compressed file. Attribute is read-only

Hope this helps u

 
I get an "Expected end of statement" error at this line:

Set f = fso.GetFile(PathTofile)f.attributes and 32 Then

Any ideas why?
 
Take off the "and 32 Then"
Set f = fso.GetFile(PathTofile)f.attributes
He pasted code that must have been in an IF

If fso.GetFile(PathTofile)f.attributes and 32 Then

 
Still get the same problem. Here's the code:
<%
objFSO.MoveFile pathsrc,pathdst
set f=objFSO.getfile(pathdst)f.attributes
f.attributes = 1
fileattributes=f.attributes
%>
 
Did not take enough. Take off the &quot;f.attributes&quot;
Set f = fso.GetFile(PathTofile)

Don't forget, it will throw an error if PathtoFile is not the fully specified path and name of a file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top