SQL PHP HTML ASP JavaScript articles and free scripts to download
 

Getting the file extension and main part name

We can collect the main file name and the extension or type of the file name by using file system object in ASP. We will use the object GetExtensionName to collect the extension or file type name. Same way we can use GetFileName to get the main part of the file name. To know the base directory of the file we can use GetBaseName object.

We will use the server map path to declare the path of the file and then use the FileExists to find out the existence of the file.


Here is the complete code.

Dim OpenFileobj, FSOobj,FilePath
FilePath=Server.MapPath("images/all11.css")
Set FSOobj = Server.CreateObject("Scripting.FileSystemObject")
if FSOobj.fileExists(FilePath) Then

Response.Write "file Exist"
Response.Write "<br>File Extension Name: "&FSOobj.GetExtensionName(FilePath)
Response.Write "<br>File Name: "&FSOobj.GetFileName(FilePath)
Response.Write "<br>File Base Name: "&FSOobj.GetBaseName(FilePath)
Response.Write "<br>File Base Name: "&FSOobj.GetBaseName("K:php_filesafile")
Else
Response.Write "File does not exist"
End if
Set FSOobj = Nothing




Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked


Join Our Email List
Email:  
For Email Newsletters you can trust
File Management