Hello and welcome to the golden programming language course in the previous session, we talked about
rename, file or folder and go Lanc.
And in this session, we want to talk about the other files and directories concept.
Check either a file or directory exists.
It's that function and is not exist, function can be used to check whether a particular file or directory
exists or not as the function returns a finding for describing the named fine.
If there is an error, it will be off time pass.
Or now you can see the syntax.
Is not exist, function returns a Boolean, indicating whether the error is known to report that the
file or directory does not exist.
Now you can see the syntax of is not exist.
Now let's go to this school program to illustrate how to check if a file or directory exists.
First, we use the ISTAT function, which returns defined info is structured, describing fine if this
function returns an error.
We use the E's not exist to determine if the error is caused by the fact that the directory already
exists.
So first defined to vary event like find info and enrolled calling equals invalid stat function from
all this package.
O.
S Dot stats
and set file name for the example 10.
Now, right, that is not exist.
Function is not text function returns a Boolean, indicating whether the error is known to report that
the file or directory does not exist.
So if Invoke is not expulsion from all aspects, OS dog is not exist and set a all go to the bot, his
statement.
In this case, if is not exist, function return a true value, write a statement based on the fact
that the file does not exist.
So from the large package that photog and set a message like backslash, a file
does not exist
now.
Display defined in variable that describes the file structure by print and function from like package
la dah print and set fire info as arguement saved the project and execute the program.
Now we can see the output, the these is fine is not available, so the program enters the eve block
and an arrow related to absence of the fine is displayed.
We are already doing these to check if a folder exists or not.
So change the fine name to a folder and change the message folder and see it is valid for all the info
and change your folder info reformat format the code save the project and again execute the program.
Now we can see down that these are folder does not exist and the program into the if block and an error
related to the absent of the folder is display.
So we were able to check the existence or not existence of a file or folder using the ISTAT and is not
exist functions in order not to prolong the time of decision.
We will finish it and we will continue the content in the next session.
Goodbye.