Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old April 30th, 2007, 12:38 AM
Friend of Wrox
 
Join Date: Aug 2006
Location: Bangalore, Karnataka, India.
Posts: 231
Thanks: 0
Thanked 1 Time in 1 Post
Default split function

hello to all
i am using file upload control to upload file. the full path of file is saved in database like c:\abc\bnh\as.doc.
i want to show this file name in data grid , but only the name like as.doc ,
for this i am thinking about split function please tell what syntax i will have to use for this. or if there is any better solution.



thanks......
__________________
thanks......
  #2 (permalink)  
Old April 30th, 2007, 02:31 AM
Friend of Wrox
Points: 1,935, Level: 17
Points: 1,935, Level: 17 Points: 1,935, Level: 17 Points: 1,935, Level: 17
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2004
Location: United Kingdom
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Simply try this:

string sValue = "c:/abc/bnh/as.doc";
Response.Write(sValue.Substring(sValue.LastIndexOf ("/") + 1));

Regards
Mike

Fortune favours the brave, so don't regret on missed oppurtunities.
  #3 (permalink)  
Old April 30th, 2007, 05:57 AM
Friend of Wrox
 
Join Date: Aug 2006
Location: Bangalore, Karnataka, India.
Posts: 231
Thanks: 0
Thanked 1 Time in 1 Post
Default

Thanks A Lot

Munish
  #4 (permalink)  
Old May 1st, 2007, 08:03 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Although, a better solution would be to use the built in method: System.IO.Path.GetFileName()

This will give you just the file name:

string sValue = "c:/abc/bnh/as.doc";
sValue = System.IO.Path.GetFileName(sValue); //sValue now == "as.doc"

http://msdn2.microsoft.com/en-us/lib...tfilename.aspx

-Peter
  #5 (permalink)  
Old May 1st, 2007, 10:05 AM
Friend of Wrox
Points: 1,935, Level: 17
Points: 1,935, Level: 17 Points: 1,935, Level: 17 Points: 1,935, Level: 17
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2004
Location: United Kingdom
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Ya

I absolutely agree with peter, I too personally use the method GetFileName().

Regards
Mike

Fortune favours the brave, so don't regret on missed oppurtunities.


Similar Threads
Thread Thread Starter Forum Replies Last Post
split function equivalent asmotritsky SQL Server 2000 4 January 5th, 2009 08:40 AM
Split function using ASp *Urgent* deean Classic ASP XML 5 June 20th, 2008 05:42 PM
using the split function jd_erd Access 2 May 7th, 2007 09:59 PM
using 'Split' function p_gauri7 Crystal Reports 0 March 11th, 2005 01:02 PM
Split function Beulah ASP.NET 1.0 and 1.1 Basics 1 September 12th, 2003 09:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.