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
  1. Home
  2. General Programming
  3. C#
  4. File path problem (Path contains a space)

File path problem (Path contains a space)

Scheduled Pinned Locked Moved C#
helpquestioncsharpvisual-studioxml
4 Posts 2 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
    bonkers123
    wrote on last edited by
    #1

    Hi, I am trying to start an application from my application, which opens a default file, given it's arguments as follow:

    Process prc = new Process();
    prc.StartInfo.FileName = "azman.msc";
    prc.StartInfo.Arguments = "msxml://" + Environment.CurrentDirectory + "\\AuthorizationStore.xml"; // CurrentDirectory = C:\Users\Hugo\Documents\Visual Studio 2008\Projects\AzManTest\AzManTest\bin
    prc.Start();

    Note the current curectory is: CurrentDirectory = C:\Users\Hugo\Documents\Visual Studio 2008\Projects\AzManTest\AzManTest\bin Which contains spaces. For some or other odd reason, it does not like this ... If this directory is in such a location that there are no spaces in the Directory name, then this works fine... Can I replace the spaces of the directory with something ? How can I fix this problem. Any help would be much appreciated!

    C 1 Reply Last reply
    0
    • B bonkers123

      Hi, I am trying to start an application from my application, which opens a default file, given it's arguments as follow:

      Process prc = new Process();
      prc.StartInfo.FileName = "azman.msc";
      prc.StartInfo.Arguments = "msxml://" + Environment.CurrentDirectory + "\\AuthorizationStore.xml"; // CurrentDirectory = C:\Users\Hugo\Documents\Visual Studio 2008\Projects\AzManTest\AzManTest\bin
      prc.Start();

      Note the current curectory is: CurrentDirectory = C:\Users\Hugo\Documents\Visual Studio 2008\Projects\AzManTest\AzManTest\bin Which contains spaces. For some or other odd reason, it does not like this ... If this directory is in such a location that there are no spaces in the Directory name, then this works fine... Can I replace the spaces of the directory with something ? How can I fix this problem. Any help would be much appreciated!

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      It's not odd, the space is used as a delimiter for arguments. Put the path in quotes to get around this.

      Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )

      B 1 Reply Last reply
      0
      • C Christian Graus

        It's not odd, the space is used as a delimiter for arguments. Put the path in quotes to get around this.

        Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )

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

        LOL .... thanks ^_^ prc.StartInfo.Arguments = "msxml://" + "\"" + Environment.CurrentDirectory + "\\AuthorizationStore.xml" + "\""; Is this the way to escape a " character?

        C 1 Reply Last reply
        0
        • B bonkers123

          LOL .... thanks ^_^ prc.StartInfo.Arguments = "msxml://" + "\"" + Environment.CurrentDirectory + "\\AuthorizationStore.xml" + "\""; Is this the way to escape a " character?

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Yes. I believe that single quotes work as well, but that's how you escape double ones.

          Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )

          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