473,394 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Extract filenames from a string

45
hi all...

i have got arequirement where in i need to take out the file names alone from a given string... i thought of using indexof function but not sure of its exact usage...

eg

there are two paths like this

str="c:\windows\temp c:\windows\dir"

i need to get the file names alone as outputs that is temp and dir...

i tried giving the index of fuction like this but its not working

int len
len=str.indexof(" ")
string str1
str1=str.substring(0,len)


but this code is not working...can anyone suggest me a solution..

wiill be thankful to whatever help i get

thanks

sairaam
May 8 '07 #1
5 1862
Killer42
8,435 Expert 8TB
The Split() function will allow you to split the string at a given character (such as a space). However, this might be a problem if the filenames contain spaces.
May 8 '07 #2
SAIRAAM
45
The Split() function will allow you to split the string at a given character (such as a space). However, this might be a problem if the filenames contain spaces.
THANKS FOR UR HELP...I DONT CLEARLY GET YOU..CAN YOU QUOTE ME WITH SOME EXAMPLE... IT WOULD BE STILL MORE HELPFUL..

SAIRAAM
May 8 '07 #3
this will like this
str=strreverse(str)
str=mid(str,1,instr(1,str,"/")-1)
str=strreverse(str)
it will help u
May 8 '07 #4
Killer42
8,435 Expert 8TB
Here's a very simple example (from VB6) of how the Split() function can be used to pull the string apart...
Expand|Select|Wrap|Line Numbers
  1. Debug.Print Split("c:\windows\temp c:\windows\dir", " ")(0)
  2. Debug.Print Split("c:\windows\temp c:\windows\dir", " ")(1)
May 8 '07 #5
SAIRAAM
45
Here's a very simple example (from VB6) of how the Split() function can be used to pull the string apart...
Expand|Select|Wrap|Line Numbers
  1. Debug.Print Split("c:\windows\temp c:\windows\dir", " ")(0)
  2. Debug.Print Split("c:\windows\temp c:\windows\dir", " ")(1)
thanks a lot sir i am able to get it now... thanks for your guidence

sairaaam
May 8 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: hokiegal99 | last post by:
This script works as I expect, except for the last section. I want the last section to actually remove all spaces from the front and/or end of filenames. For example, a file that was named " test ...
10
by: mark4 | last post by:
Hello, Are there any utilities to help me extract Content from HTML ? I'd like to store this data in a database. The HTML consists of about 10,000 files with a total size of about 160 Mb....
3
by: Bill | last post by:
Is there a method that will take a full path and filename as a parameter and return just the filename? I am currently using the following code but it is extremely slow for files on a DVD. for...
2
by: rbutch | last post by:
guys, i need a little help with this. this is working (well sort of) i get the info, but it's not moving to a new line as it iterates thru the array and all of the fields are like ONE HUGE LONG...
2
by: Taras_96 | last post by:
Hi everyone, Firstly, I would like to know if you can open chinese filenames under win2000 using PHP 5.0? I have a file named 中国.php, and try to open it using fopen(‘中国.php','r');....
7
by: erikcw | last post by:
Hi all, I'm trying to extract zip file (containing an xml file) from an email so I can process it. But I'm running up against some brick walls. I've been googling and reading all afternoon, and...
3
by: adimangla | last post by:
Hi :-) I am creating a software that will save the present state of all the applications running on the desktop (WinXP). Can anyone point out the method to extract the filenames from the...
6
by: kimiraikkonen | last post by:
Hello, I have a listbox and folder browser control. I need to display all .mp3 files' pathes into listbox. It was Ok with openfiledialog but how can list all .mp3 extension- having files into...
2
by: Art | last post by:
hey, i think this must be really easy: i want to use strings as filenames that include characters that are not allowed in windows filenames. is there a special converter method for this?...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.