Hi all!
Can someone write here a code (for script in WinCC Flex),
so I can see if my file eg. "c:\Logs\Log_1.csv" is "ReadOnly" or not?
Thanks!
[?]: WinCC Flexible Script Code for "Get file attributes"
-
- Posts: 258
- Joined: Fri Apr 03, 2009 3:24 pm
- Location: Bosnia and Herzegovina
-
- Posts: 17
- Joined: Fri Sep 24, 2010 10:03 pm
Re: [?]: WinCC Flexible Script Code for "Get file attributes
Try this:
You can use a tag ("Attrib" in my script) or an internal variable to save the attributes if the file.
The return values of Attributes-property are:
0: Normal (file without attributes)
1: ReadOnly
2: Hidden
4: System
16: Directory (not a file)
32: Archive
1024: Alias (it's a shortcut)
2048: Compressed
If the return value is 7 than it is hidden, system file for reading only (1+2+4)
Have fun!
(Scripting makes fun.)
Greets
PS: Did you try F1?
Code: Select all
On Error Resume Next
Dim FSO, File, szFolder, szFileName, iAttrib
szFolder = "C:\Temp\"
szFileName = "ExampleFile.txt"
Set FSO = CreateObject("Scripting.FileSystemObject")
If Err.Number <> 0 Then
ShowSystemAlarm Err.Description
Err.Clear
Exit Sub
End If
Set File = FSO.GetFile(szFolder & szFileName)
SmartTags("Attrib") = File.Attributes
If Err.Number <> 0 Then
ShowSystemAlarm Err.Description
Err.Clear
Exit Sub
End If
Set File = Nothing
Set FSO = Nothing
The return values of Attributes-property are:
0: Normal (file without attributes)
1: ReadOnly
2: Hidden
4: System
16: Directory (not a file)
32: Archive
1024: Alias (it's a shortcut)
2048: Compressed
If the return value is 7 than it is hidden, system file for reading only (1+2+4)
Have fun!
(Scripting makes fun.)
Greets
PS: Did you try F1?
-
- Posts: 258
- Joined: Fri Apr 03, 2009 3:24 pm
- Location: Bosnia and Herzegovina
Re: [?]: WinCC Flexible Script Code for "Get file attributes
Thanks, Lepes9!
F1 gives no help for it. You will see that they use Object.SetAttr i Object.GetAttr which is not usable, even you didn't use it.
Thanks again!
F1 gives no help for it. You will see that they use Object.SetAttr i Object.GetAttr which is not usable, even you didn't use it.
Thanks again!
-
- Posts: 17
- Joined: Fri Sep 24, 2010 10:03 pm
Re: [?]: WinCC Flexible Script Code for "Get file attributes
Hi Homeroid_BL!
If you want to change the attributes of a file you have to assign a value to the file.
E.g.:
Now the file is an archive (NOT compressed!) and read-only.
Greetings
If you want to change the attributes of a file you have to assign a value to the file.
E.g.:
Code: Select all
File.Attributes = 33
Greetings