|
-
Mar 13th, 2001, 11:27 AM
#1
Thread Starter
Lively Member
How can i obtain the name of a filename without its extension ? I mean if the filename is 1bitmap.jpg , then how can i obtain "1bitmap" of this particular filename ?
-
Mar 13th, 2001, 03:04 PM
#2
Code:
sFile = "Bitmap1.bmp"
sFile = Left(sFile, InStr(1, sFile, ".") - 1)
Print sFile
-
Mar 14th, 2001, 02:40 AM
#3
of course that assumes that there IS an extension.
If there isn't you lose the entire file name. This small adjustment will fix that.
sFile = "Bitmap1.bmp"
pos = instrev(sFile, ".") -1
if pos > 0 then sFile = Left(sFile, InStRev(1, sFile, ".") - 1)
Print sFile
This also takes into account multiple dots in a file name.
Now all you have to worry about is a file name with a dot in it, but no extension.
Of course you could test for that with a dir$ statement when you are done.
if dir$(filename + ".*") = "" then error
sFile = "Bit.map1"
pos = instrev(sFile, ".") -1
if pos > 0 then sFile2 = Left(sFile, InStRev(1, sFile, ".") - 1)
if dir$(sfile2 + ".*") = "" then sfile2 = sfile1
print sfile2
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|