How to cut a string to the first "/" from right to left c# .net

Stack Overflow Asked by Ignacio Gomez on August 1, 2020

I need to remove from my string the last section from the ""

          Input: C:qaweb2094Sitedasdasd.pdf
Expected Output: C:qaweb2094Site

One Answer

You can try the below code

string s = "C:\qaweb2094\Site\dasdasd.pdf";
if (s.Contains("\"))
    s = s.Substring(0, s.LastIndexOf("\"));

Correct answer by Sowmyadhar Gourishetty on August 1, 2020

Add your own answers!

Related Questions

Remove item from state

3  Asked on December 5, 2020 by clayton-crockville


How to concatenate 3 lists even if there are a list null?

2  Asked on December 5, 2020 by alexz


Angular 8: Select first element of ng-content

1  Asked on December 5, 2020 by ijustdev


docker-compose volume empty

3  Asked on December 5, 2020 by kerby82


Extract value of column from a line (variable)

4  Asked on December 4, 2020 by user4516211


Merge Two Files in Weka based on date

1  Asked on December 4, 2020 by spwath


Set Session ID Cookie in Nuxt Auth

1  Asked on December 4, 2020 by dominooch


Warnings in gcc compiler

1  Asked on December 3, 2020 by hygor-marques


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir