none
Deleting part of a string - VB.NET RRS feed

  • Question

  • I have a filename like this: "C:\\Desktop\filename.png"

    I want to delete everything on that string except the "filename". So I deleted "C:\\Desktop\" and ".png".

    How do I do that in VB.NET? Thanks in advance.


    JDS404 Check out my blog at www.interlinkjds.wordpress.com!

    Tuesday, July 1, 2014 8:38 PM

Answers

  • Try this...        

    Dim ext AsString= IO.Path.GetExtension(fullPathName)

    Dim  noExt AsString= IO.Path.GetFileNameWithoutExtension(fullPathName)

    The first will give you "png" and the second wll give you "filename".   These calls are not specific to VB.NET and work with C# too.


    ...Jim Black


    • Edited by Jim Black CG Tuesday, July 1, 2014 8:44 PM typo
    • Marked as answer by JDS404 Tuesday, July 1, 2014 8:51 PM
    Tuesday, July 1, 2014 8:43 PM

All replies

  • Try this...        

    Dim ext AsString= IO.Path.GetExtension(fullPathName)

    Dim  noExt AsString= IO.Path.GetFileNameWithoutExtension(fullPathName)

    The first will give you "png" and the second wll give you "filename".   These calls are not specific to VB.NET and work with C# too.


    ...Jim Black


    • Edited by Jim Black CG Tuesday, July 1, 2014 8:44 PM typo
    • Marked as answer by JDS404 Tuesday, July 1, 2014 8:51 PM
    Tuesday, July 1, 2014 8:43 PM
  • Try this...        

    Dim ext AsString= IO.Path.GetExtension(fullPathName)

    Dim  noExt AsString= IO.Path.GetFileNameWithoutExtension(fullPathName)

    The first will give you "png" and the second wll give you "filename".   These calls are not specific to VB.NET and work with C# too.


    ...Jim Black



    Thanks for that, it worked - speedy reply, by the way!

    JDS404 Check out my blog at www.interlinkjds.wordpress.com!

    Tuesday, July 1, 2014 8:51 PM
  • Glad to help.  Don't forget to mark the question as answered so it will help others with the same question!

    ...Jim Black

    Tuesday, July 1, 2014 8:57 PM