CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2010
    Posts
    24

    Dumb Question: String dividing.

    Okay, I have a file name + directory as a string. What I'm trying to do is separate the file name (with or without) an extension from the rest of the directory. The point is that it is supposed to be a dynamic file location and the file extension is NOT limited to 3 characters. What would the best way to approach this be?

    P.S. Kinda dumb question, I know, but I'm trying to learn. Any pointers or examples would be greatly appreciated

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Dumb Question: String dividing.

    How about?

    Code:
    FilenameObject.Extension
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Dumb Question: String dividing.

    yep

    You could also use .Split() using \ as the seperator and look at the last element of the resulting array but the method above would be a better choice. Just throwing this in so that you know it is an option.
    Always use [code][/code] tags when posting code.

  4. #4
    Join Date
    Sep 2010
    Posts
    24

    Re: Dumb Question: String dividing.

    Thanks a ton, guys! Sorry for it being such a dumb question, but like I said, I'm learning :P

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured