Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get the file name

Status
Not open for further replies.

discusmania

IS-IT--Management
Oct 24, 2000
158
AP

hi guys...
this is the value of html file control
D:\Profiles\12009979\My Documents\Batch Insert.doc

what i want is i want to be able to break the value into filename, file extention, folders and so on....what should i do?

thanks
 
Use string manipulation to break off the parts. So you could use something like:
<%
'====================================================================
' Function will get the file name from the full path.
'====================================================================
Function extractFilename(pathName)
extractFilename = Mid(pathName, InstrRev(pathName, &quot;\&quot;) + 1)
If extractFilename = pathName Then
extractFilename = Mid(pathName, InstrRev(pathName, &quot;/&quot;) + 1)
End If
End Function

%>

The function just searches from the end of the string, for the first slash, indicating the start of filename. The VBscript language reference is very useful for such things as they have a different approach than some other langauges like Java.
I recommend downloading the whole thing, it has helped me no end.


There is a link to downloads on the left
bj
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top