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!

Ask a Question

Get help from others!

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