Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. VB.NET defining space characters in a string?

VB.NET defining space characters in a string?

Scheduled Pinned Locked Moved Visual Basic
csharpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Benny_Lava
    wrote on last edited by
    #1

    Hi, I am creating a stream : stream = file.create(filePAth) 'And it pops up a message here saying : "Illegal characters in path" I have searched high and wide for illegal character, in normal view and hex, and there is none. The only thing I can think of is the space character, I have searched google and found some things that can be done to prevent this usign @ in front of the string, but it doesn't work in VB. Any ideas? Thanks!

    Y E 2 Replies Last reply
    0
    • B Benny_Lava

      Hi, I am creating a stream : stream = file.create(filePAth) 'And it pops up a message here saying : "Illegal characters in path" I have searched high and wide for illegal character, in normal view and hex, and there is none. The only thing I can think of is the space character, I have searched google and found some things that can be done to prevent this usign @ in front of the string, but it doesn't work in VB. Any ideas? Thanks!

      Y Offline
      Y Offline
      yogesh_kumar_agarwal
      wrote on last edited by
      #2

      hi first try it by using the static path like c:\ if it works fine then go for filePath variable and in that if want to remove only tralling and starting spaces then use Trim(filePath) else you could go for a loop like this dim a as string for i=0 to len(filePath)-1 if mid(filePath,i,1)<>" " then a=a+mid(filePath,i,1) endif next now a will the string without spaces Yogesh Agarwal

      B 1 Reply Last reply
      0
      • Y yogesh_kumar_agarwal

        hi first try it by using the static path like c:\ if it works fine then go for filePath variable and in that if want to remove only tralling and starting spaces then use Trim(filePath) else you could go for a loop like this dim a as string for i=0 to len(filePath)-1 if mid(filePath,i,1)<>" " then a=a+mid(filePath,i,1) endif next now a will the string without spaces Yogesh Agarwal

        B Offline
        B Offline
        Benny_Lava
        wrote on last edited by
        #3

        Yes I know that, but I cannot change the string, this is an absolute path. The path cannot be changed... I just need to tell the compiler, or that function or someone... that there is a space in the PATH string. So it can handle the space... The path cannot be changed! any other ideas. Thanks

        1 Reply Last reply
        0
        • B Benny_Lava

          Hi, I am creating a stream : stream = file.create(filePAth) 'And it pops up a message here saying : "Illegal characters in path" I have searched high and wide for illegal character, in normal view and hex, and there is none. The only thing I can think of is the space character, I have searched google and found some things that can be done to prevent this usign @ in front of the string, but it doesn't work in VB. Any ideas? Thanks!

          E Offline
          E Offline
          Eslam Afifi
          wrote on last edited by
          #4

          It's not about space characters. Your path has invalid characters. This code is a prove that space character is not the problem.

          IO.File.Create("c:\ .txt")
          

          Use this code to get where the invalid characters are.

          filePAth.IndexOfAny(System.IO.Path.GetInvalidPathChars())
          

          Eslam Afifi

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups