Process.start("winword", filename) can not open file with space in the path and name

Hi,
I am trying to write a class which can open file with selected application. for simplicity, now I just hard code the varaibles.
the problem: if the path or file name has space in it, even it exist, winword still can not open it.
could someone kindly show me what I did wrong and how to do it properly.
Thanks in advance.
Belinda
public static class FileOpen
public static void info()
string path = @"c:\a temp folder\aaa 1.txt";
if (File.Exists(path))
    // the file I am using in the sample does exist
     MsgBox.info("yes");
else
     MsgBox.info("no");
// working
//Process.Start("winword", "c:\\aaa.txt");
// not working
//Process.Start("winword", "c:\aaa.txt");
// not working
Process.Start("winword", "c:\\a temp folder\\aaa 1.txt");
// not working
Process.Start("winword", path);

string AppPath;
AppPath = ReadRegistry(Registry.CurrentUser, "Software\\FabricStudio", "TARGETDIR", value).ToString() + @"help";
string FileName = "'"+ AppPath + "\\ImageSamples.doc" + "'";
try
System.Diagnostics.Process.Start("Winword.exe", FileName);
can any body please help for this.
where i am making mistake?

Similar Messages

  • LibreOffice can't open files with spaces in the name

    Hi, so I recently installed LibreOffice (from extra) over go-OO. I know the site says it's not for production use but I have heard good things about the stability of the current version so I decided to see if it was in a usable state. In general things are going great, but I do have the problem mentioned in the thread title. The program has trouble parsing the spaces, and instead I am trying to open each space-delimited section of the filename as a separate file. Trying to open "My File.odt", for example, will simply return two error messages, one about "path/to/current/directory/My" not existing, and another about "path/to/current/directory/File.odt" not existing. I can't seem to get around this behaviour and, surprisingly, I can't find anything on it by Googling.
    I know that LO is in beta and this may just be a bug that is being worked on, but since I can only find one reference to it on the net I thought that maybe others were not having this problem or had found a way around it.  Can anyone provide any insight? Cheers!

    vimex wrote:
    comment these lines in /usr/lib/ooo-3.3/program/soffice
    the $* has some problem, but I do not know how to correct this...
    # Setup our app as oosplash, but try to avoid executing pagein,
    # and other expensive environment setup pieces wherever possible
    # for a second started office
    #if [ "$sd_binary" = "soffice.bin" -a -x "$sd_prog/oosplash.bin" ] && [ "$no_oosplash" != "y" ] ; then
    #    sd_binary="oosplash.bin"
    #    export QSTART_CHECK_ONLY=1
    #    if "$sd_prog/$sd_binary" $*; then
    #   exit 0
    #    fi
    #    unset QSTART_CHECK_ONLY
    #fi
    I noticed that commenting out that code allows LibreOffice to open spaced filenames, but seems to slightly increase startup time.
    I tried replacing $* with "$*", and opening from the command line seems to work even for files with spaced names, with the faster startup time too. The only problem is that now LO does not work at all by clicking; only from command line.

  • Programmatic launch of reader 11.0.3 won't open file with spaces in the path?

    The application I work on uses a PDF file for online help.  We programmatically launch the help file into the user's PDF viewer.  The path to the help file may have spaces in the directory names or filename.  With previous versions of Adobe Reader, it would launch just fine (path passed in on the command line).  However, with 11.0.3, I find that if I don't include an extra set of quotation marks around the path, it fails to open when there are spaces in the directory name.  What changed between then and now to cause this problem?  If I add extra quotation marks, will users with an older version of Reader not be able to open the file?
    Edit -- running in Windows 7, launched from C# .NET 3.5.

    benten2000 wrote:
    Install is fine and the icon is shown on the desktop and pdf files icons also change to Acrobat.
    I seem to have missed this part when reading your original post.  See if anything in this article fixes your problem: http://helpx.adobe.com/acrobat/kb/application-file-icons-change-acrobat.html

  • Adobe Reader XI does not open files with a command line "path" argument.

    Adobe Reader XI does not open files with a command line "path" argument. Version X and lower all worked fine. I have deleted and reinstalled the program with no success. Is this a bug?

    Hi Daniel,
    What is the make of the printer and is it using PCL or PS driver.?
    Do you have Acrobat installed on this machine as well?
    Please check if 'Print Spooler' service is running on the machine.
    Regards,
    Rave

  • Bug: can't access static files with space in the path

    Please let me know if this a a wrong place to file bug reports.
    I installed webserver7u4 and when I try to access a static file within my war which contains a space in the path, I get HTTP404.
    $ ls webserver7/https-myapp/web-app/myapp/_default/images/ddtree/black\ spinner/1.png
    webserver7/https-myapp/web-app/myapp/_default/images/ddtree/black spinner/1.png
    $ wget -O /dev/null "http://localhost:8080/images/ddtree/black spinner/1.png
    "--13:47:06-- http://localhost:8080/images/ddtree/black%20spinner/1.png
    => `/dev/null'
    Resolving localhost... 127.0.0.1, ::1
    Connecting to localhost|127.0.0.1|:8080... connected.
    HTTP request sent, awaiting response... 404 Not found
    13:47:06 ERROR 404: Not found.Now, if I create a symlink to a path that contains url encoded space, everything works:
    $ ls -l webserver7/https-myapp/web-app/myapp/_default/images/ddtree/black%20spinner
    lrwxrwxrwx 1 root root 13 Aug 1 2008 webserver7/https-myapp/web-app/myapp/_default/images/ddtree/black%20spinner -> black spinner
    $ wget -O /dev/null "http://localhost:8080/images/ddtree/black spinner/1.png"
    --13:49:37-- http://localhost:8080/images/ddtree/black%20spinner/1.png
    => `/dev/null'
    Resolving localhost... 127.0.0.1, ::1
    Connecting to localhost|127.0.0.1|:8080... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 1,446 (1.4K) [image/png]
    100%[======================================================================== =======================================>] 1,446 --.--K/s
    13:49:37 (89.76 MB/s) - `/dev/null' saved [1446/1446]So to me it appears that webserver doesn't decode the path before searching the local file system, which to me looks like a bug.
    Let me know if you need more info.
    cheers,
    Igor

    HTTP/1.1 RFC [http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.2|http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.2]
    3.2 Uniform Resource Identifiers
    URIs have been known by many names: WWW addresses, Universal Document Identifiers,
    Universal Resource Identifiers [3], and finally the combination of
    Uniform Resource Locators (URL) [4] and Names (URN)  ... where
    3 is a link to [http://www.ietf.org/rfc/rfc1630.txt|http://www.ietf.org/rfc/rfc1630.txt] section BNF for specific URL schemes
      httpaddress              h t t p :   / / hostport [  / path ] [ ?search ]
      path                   void |  segment  [  / path ]
      segment                xpalphas
      xpalphas               xpalpha [ xpalphas ]
      xpalpha                xalpha | +
      xalpha                 alpha | digit | safe | extra | escape
      alpha                  a | b | c | d | e | f | g | h | i | j | k |
                             l | m | n | o  | p | q | r | s | t | u | v |
                             w | x | y | z | A | B | C  | D | E | F | G |
                             H | I | J | K | L | M | N | O | P |  Q | R |
                             S | T | U | V | W | X | Y | Z
      digit                  0 |1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
      safe                   $ | - | _ | @ | . | &  | + | -
      extra                  ! | * |  " |  ' | ( | )  | ,
      escape                 % hex hex
      hex                    digit | a | b | c | d | e | f | A | B | C | D | E | F{code}
    4 is a link to RFC 1738 Uniform Resource Locators (URL)
    [http://www.ietf.org/rfc/rfc1738.txt|http://www.ietf.org/rfc/rfc1738.txt] section 5. BNF for specific URL schemes
    has :
    {code}
    httpurl        = "http://" hostport [ "/" hpath [ "?" search ]]
    hpath          = hsegment *[ "/" hsegment ]
    hsegment       = *[ uchar | ";" | ":" | "@" | "&" | "=" ]
    uchar          = unreserved | escape
    escape         = "%" hex hex
    hex            = digit | "A" | "B" | "C" | "D" | "E" | "F" |
                                 "a" | "b" | "c" | "d" | "e" | "f"
    unreserved     = alpha | digit | safe | extra
    alpha          = lowalpha | hialpha
    lowalpha       = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" |
                     "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" |
                     "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" |
                     "y" | "z"
    hialpha        = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" |
                     "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" |
                     "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z"
    digit          = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" |"8" | "9"
    safe           = "$" | "-" | "_" | "." | "+"
    extra          = "!" | "*" | "'" | "(" | ")" | ","
    {code}
    I do not see space in these RFCs for httpurl.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Why the const char* filename can not open file?

    the jni pass the string, I then convert it to the
    const char* filename = env->GetStringUTFChars(fname,NULL);
    then I use the filename to opent the file but fails, what is the problem???
    FILE *fp= fopen(filename,"w"); // there are some problem here!!!
         fprintf(fp, "%s\n","wangyue fighting!");
    the error is as follows
    # An unexpected error has been detected by Java Runtime Environment:
    # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0bfc1a55, pid=7040, tid=11384
    # Java VM: Java HotSpot(TM) Client VM (10.0-b19 mixed mode windows-x86)
    # Problematic frame:
    # C [beattrack.dll+0x1a55]
    # An error report file with more information is saved as:
    # D:\programs\playAudio\hs_err_pid7040.log
    # If you would like to submit a bug report, please visit:
    # http://java.sun.com/webapps/bugreport/crash.jsp
    # The crash happened outside the Java Virtual Machine in native code.
    # See problematic frame for where to report the bug.
    #

    Danielwang wrote:
    the jni pass the string, I then convert it to the
    const char* filename = env->GetStringUTFChars(fname,NULL);
    then I use the filename to opent the file but fails, what is the problem???
    Same as your previous problem.
    FILE *fp= fopen(filename,"w"); // there are some problem here!!!No that is not where the problem is.

  • [SOLVED]Audacious can't open files with spaces on name

    I open audacious
    Type Ctrl+o and select a directory with spaces on it names,
    Audacious opens nothing
    Any ideas?
    I have deep trees of music with spaces, I was working on a script to rename one by one, but I'm too lazy
    Cheers
    Last edited by geckos (2014-01-29 21:32:33)

    Here is my solution, I did this for every error that apears like that...
    [geckos@localhost ~]$ audacious
    (bootstrap.c:60) [mowgli_init]: mowgli_init() is a deprecated function, provided only for backwards compatibility with Mowgli-1. You should remove it if you no longer support using Mowgli-1.
    *** ERROR: /usr/lib/audacious/Input/cdaudio-ng.so could not be loaded: libcdio_cdda.so.1: cannot open shared object file: No such file or directory
    ^C[geckos@localhost ~]$
    [geckos@localhost ~]$ pkgfile -r '.*/libcdio_cdda.so.1'
    extra/libcdio-paranoia
    [geckos@localhost ~]$ sudo pacman -Syu libcdio-paranoia
    :: Synchronizing package databases...
    (3/3) installing libcdio-paranoia [###########################################] 100%
    [geckos@localhost ~]$
    [geckos@localhost ~]$

  • Can't email files with spaces in the file name since 10.5.2 upgrade

    Not sure if this is a bug with Leopard or I'm being stupid (possibly the later) but... Has anyone else experienced this issue and do you know what is causing it? I am currently unable to send a file that has a space in the file name. The only change on my system that has occurred since I last sent and email in a similar way is I've updated my OS from 10.5.1 to 10.5.2. Any ideas how to fix it?

    Sorted. Well sort of. I still have the problem but I know why. Apparently O2 will not allow anyone to send an attachment which has a space in the name. They claim that this reduces spam - no idea why they think that will stop spam but there you go...

  • Unable to access files with spaces in the path

    Hi all, I am accessing files which reside on the server using a java applet.
    The typical path of a file could be:
    http://192.168.0.2/agat/data/AF190701 0003.agt
    (not the space in the filename).
    When I try to open this file using a URL object:
    URL file = new URL(filename);
    BufferedReader in = new BufferedReader(new InputStreamReader(file.openStream()));
    I get exception 400 ( I think) whihc I assume is file cant be found.
    However when I rename the file (to get rid of that space) and also change the filename variable to suit. The file is opened as expected.
    What should I do to make the applet able to open paths with spaces? Or is this just not possible.
    I did try including quotes with the special characte precessor:
    filename = "/"http://192.168.0.2/agat/data/AF190701 0003.agt/""
    But this didnt work either, please could someone tell what I need.
    Thanks.

    Thanks guys, although before I got your replies I did the following - it seems to work, but shall try your suggestions.
    while (file.lastIndexOf(" ") >0)
    String temp;
    int num = file.lastIndexOf(" ");
    temp = file.substring(0, num) + "%20" + file.substring(num+1, file.length());
    file = temp;
    }

  • Can't open files with spaces from gui applications

    When I try to open a file or directory from say qbittorrent or clementine in xfce, I get the message:
    "Failed to open URI "file:///somewhere/filename%20with%20spaces".
    Googling told me this problem was due to passing a "%U" instead of a "%F" somwhere, but I don't know where to change this.

    I don't use any DE or those kinds of gui tools, but the "%U" instead of an "%F" issue would be in the .desktop files.  There are systemwide .desktop files in /usr/share/applications/ and you can override these with your own customized versions in ~/.local/share/applications/
    So a workaround at least would be to copy the relevant desktop files from the system-wide folder to your user's folder and edit them appropriately changing %U to%F.

  • Hello Sorry for the inconvenience, but I have a problem in Java I can not open files, audio chat, which type of jnlp after the last update of the Java 2012-004 Please help me in solving this problem.

    Hello Sorry for the inconvenience, but I have a problem in Java I can not open files, audio chat, which type of jnlp after the last update of the Java 2012-004
    Please help me in solving this problem. 

    Make sure Java is enable in your browser's security settings.
    Open Java Preferences (in Utilities folder)
    Make sure Web-start applications are enabled.
    Drag Java 32-bit to the top of the list.
    jnlp isn't an audio file format. It's just a java web-start program (Java Network Launching Protocol).

  • After update to OS X Maverick I can not open files in Lotus Notes Smart suite. Is there any way to solve this problem?

    After I updated to OS X Maverick I can not open files in Lotus Notes Smart suite. Is there any way to solve this problem?

    Ok this worked to solve the error.
    Use cmd prompt in windows 7 or 8 and run as admin:
    sc config lanmanworkstation depend= bowser/mrxsmb10/nsi
    sc config mrxsmb20 start= disabled
    No need for all that power shell nonsense as shown elsewhere for windows 8.
    That's it. Also force smb2 disabling on the apple side for good measure.
    With the above I was able to network mavericks and windows 8.1 pro flawlessly. He issues I had before where I could not read video, ISO and audio files (but could open documents and pictures from the windows machine connected to an apple network share folder went away.

  • After o download the browser ,i get message that says can not open file what do i need to do to download the browser i have tried 5 times get same message

    its the same shit i asked before after i download the browser i get message can not open file what do i do to dwonload the browser

    That message is usually a sign that you tried to roll back to an earlier build of iTunes, but occasionally I've seen it connected to a new upgrade. This technique should fix things.
    Empty/corrupt library after upgrade/crash
    Hopefully it's not been too long since you last upgraded iTunes, in fact if you get an empty/incomplete library immediately after upgrading then with the following steps you shouldn't lose a thing or need to do any further housekeeping. In the Previous iTunes Libraries folder should be a number of dated iTunes Library files. Take the most recent of these and copy it into the iTunes folder. Rename iTunes Library.itl as iTunes Library (Corrupt).itl and then rename the restored file as iTunes Library.itl. Start iTunes. Should all be good, bar any recent additions to or deletions from your library.
    See iTunes Folder Watch for a tool to catch up with any changes since the backup file was created.
    When you get it all working make a backup!
    tt2

  • Adobe photoshop lightroom won't install on my Mac - error can not open file

    Adobe Photoshop Lightroom4 will not install on my Mac. "Error can not open file" when trying to open will installer. If I cannot get it to work I would like to return product.

    What version of Mac OS are you using?  What is the exact name of the file which you are double clicking on?  If you right click on the file and select Get Info what does it state under the Open With section?

  • I can not open files created in iWork 6 or iWork 8 with pages 5.2. I removed the older versions and emptied my trash.  what to do?

    i can not open files created in iWork 6 or iWork 8 with pages 5.2. I removed the older versions and emptied my trash.  what to do?

    Reinstall iWork '08 which can export to Word .doc/x files.
    Peter

Maybe you are looking for