FileExists : Vérifier si un fichier existe ou non
Page 1 sur 1
FileExists : Vérifier si un fichier existe ou non
METHOD: FileSystemObject.FileExists
--------------------------------------------------------------------------------
Implemented in version 2.0
object.FileExists(file)
This method lets us check if a specified file exists. It returns a Boolean value - True if the file does exist and False if it doesn't. Note that if the file that you are checking for isn't in the current directory, you must supply the complete path.
In the following example the FileExists method is used to check for a specific file before deleting it.
Code:
<%
dim filesys
Set filesys = CreateObject("Scripting.FileSystemObject")
filesys.CreateTextFile "c:\somefile.txt", True
If filesys.FileExists("c:\somefile.txt") Then
filesys.DeleteFile "c:\somefile.txt"
Response.Write("File deleted")
End If
%>
Output:
"File deleted"
--------------------------------------------------------------------------------
Implemented in version 2.0
object.FileExists(file)
This method lets us check if a specified file exists. It returns a Boolean value - True if the file does exist and False if it doesn't. Note that if the file that you are checking for isn't in the current directory, you must supply the complete path.
In the following example the FileExists method is used to check for a specific file before deleting it.
Code:
<%
dim filesys
Set filesys = CreateObject("Scripting.FileSystemObject")
filesys.CreateTextFile "c:\somefile.txt", True
If filesys.FileExists("c:\somefile.txt") Then
filesys.DeleteFile "c:\somefile.txt"
Response.Write("File deleted")
End If
%>
Output:
"File deleted"
Sujets similaires
» Opération sur fichier txt
» Opération sur fichier txt II
» Faire un merge d'un fichier Reg
» Movefile : déplacer ou renommer un fichier
» Création de fichier MST à partir d'une source MSI
» Opération sur fichier txt II
» Faire un merge d'un fichier Reg
» Movefile : déplacer ou renommer un fichier
» Création de fichier MST à partir d'une source MSI
Page 1 sur 1
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum