What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 1530 |  Welcome, Guest!   Register  Login
 Home > Forums > ASP.NET > How to get the last two characters in string ...
Kavi.Sirius

How to get the last two characters in string

Replies: 3 | Posted by: Kavi.Sirius on 5/14/2012 | Category: ASP.NET Forums | Views: 1112 | Status: [Member] | Points: 10  


hi,

string url="D:\Kavi\WebSite3\Test\ET_Seating Management System_URD_V0_pdf.pdf";

in this url string i need to get the last two characters only with the backslash

Test\ET_Seating Management System_URD_V0_pdf.pdf

how can i get

Thanks in advance...

Regards
Kavi.n


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Sakthi.Singaravel
Sakthi.Singaravel  
Posted on: 5/14/2012 4:54:12 AM
Level: Silver | Status: [Member] | Points: 25

ur url string must end with .pdf....?

Regards,
Singaravel M

Kavi.Sirius, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Sakthi.Singaravel
Sakthi.Singaravel  
Posted on: 5/14/2012 5:11:30 AM
Level: Silver | Status: [Member] | Points: 50

Resolved

string url = "D:\Kavi\WebSite3\Test\ET_Seating Management System_URD_V0_pdf.pdf";

string temp_url = Regex.Replace(url, "(.*?)(\\(.[^\\]*?)\\(.[^\\]*?)\.pdf)$", "$2");



Regards,
Singaravel M

Kavi.Sirius, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Sriramnandha
Sriramnandha  
Posted on: 5/23/2012 9:01:18 AM
Level: Starter | Status: [Member] | Points: 25

HI,

ASPX PAGE:


<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"

CodeBehind="Default.aspx.cs" Inherits="fetchlastcharacter._Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<h2>
Welcome to ASP.NET!
</h2>
<p>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</p>
<p>
&nbsp;</p>
<p>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</p>
<p>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
</p>
</asp:Content>


ASPX.CS

using System;

using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace fetchlastcharacter
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

protected void Button1_Click(object sender, EventArgs e)
{

string retString = null;
retString =TextBox1.Text.Substring(16, 45);
TextBox2.Text = retString;

}
}
}




OUTPUT:

Test\ET_Seating Management System_URD_V0_pdf.pdf


HOPE THIS WILL HELP

REGARDS

sriram

Kavi.Sirius, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

Found interesting? Add this to:


 Latest Posts

Write New Post | More ...

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/25/2013 1:04:34 PM