Check if file exists in VBscript (WinCC Flex)

userxyz

Member
Join Date
May 2002
Location
any
Posts
2,768
What do I need:
When They want to do an Import, this is called:
Code:
DeleteDataRecordMemory hmiFlashMemory, hmiOff, hmiOn, SmartTags("PERS_REC_MEMORY_CLEAR")

If Err.Number <> 0 Then
	ShowSystemAlarm "Error #" & Err.Number & " " & Err.Description
	Err.Clear 
	Exit Sub
End If
ImportDataRecords "\\pcg4\Shared\recs_PERSPROGRAMMA.csv", 0, hmiOverwriteAlways, hmiOn, SmartTags("IMPORT_PERS_STATUS")
If Err.Number <> 0 Then
	ShowSystemAlarm "Error #" & Err.Number & " " & Err.Description
	Err.Clear 
	Exit Sub
End If

But now I want to check first if the csv file exists ==>> Try:

Code:
Dim f, fs, filename

Set f= CreateObject("filectl.file")
Set fs = CreateObject("filectl.filesystem")

filename="\\pcg4\Shared\recs_PERSPROGRAMMA.csv"
If fs.dir(filename) = "\\pcg4\Shared\recs_PERSPROGRAMMA.csv" Then 
'IMPORT POSSIBLE
End If

Or is this the way to go:

filename="\\pcg4\Shared\recs_PERSPROGRAMMA.csv"
If fs.dir(filename) = "" Then
'end
Else
'import
End If
Should this work or should it be written in an other way ?

Thanks in advance,
regards,
Combo
 
Last edited:

Similar Topics

Hello all, I have a Controllogix 1756-L61 with some RIO. There are a couple of 1734-OB4E's that have gone bad. (no output voltage) My boss found...
Replies
10
Views
1,086
Hello I am new here and new to PLC's, I wrote this program for a class that I am taking and my local tech school. The description is switch 7 will...
Replies
0
Views
422
Hello I am new here and new to PLC's, I wrote this program for a class that I am taking and my local tech school. The description is switch 7 will...
Replies
10
Views
1,993
I'm trying to save a project as an L5X and I need to uncheck the "Encode Source Protected Content" checkbox, but it's grayed out. How do I get...
Replies
1
Views
950
Hello. I have been working on my first plc project for a while now. I just ordered all the parts that I need and before I did that, I created the...
Replies
10
Views
2,054
Back
Top Bottom