none
Document could not be openedSystem.ComponentModel.Win32Exception RRS feed

  • Question

  • Hi,

    I am getting an error while openning an image file  by using "System.Diagnostics.Process.Start(localFilename)". on window server OS,However it open txt file and pdf files normally.

    Failed to locate the local copy of the selected document. Document could not be openedSystem.ComponentModel.Win32Exception: The specified file is not a program associated

        at System.Diagnostics.Process.StartWithShellExecuteEx (ProcessStartInfo start info)
        at System.Diagnostics.Process.Start ()
        at System.Diagnostics.Process.Start (ProcessStartInfo start info)
        at System.Diagnostics.Process.Start (String fileName)..But its Working Fine om my window 7 operating system.

    I don't know why it happens ,Please suggest.

    Thanks


    rishi [URL=http://miniclipgames.name/ ]miniclip[/URL], [URL=http://www.btjunkie.name/ ]btjunkie[/URL], [URL=http://www.freedownloadgames.name/ ]games[/URL]


    • Edited by Rishi90 Monday, December 10, 2012 5:59 AM
    Monday, December 10, 2012 5:57 AM

Answers

  • Looks like you have to give the associated program name. For, example, most of the image files can be opened in MSPaint. So, you can change your code as below. If that works, then it means there is no associated program that can open your image file. If it doesn't work, then possibly the image file is corrupted.

    System.Diagnostics.Process.Start("MSPaint.exe", localFilename);

    You can also replace "MSPaint.exe" with any other program name that can open your image file.

    I hope this helps.


    Please mark this post as answer if it solved your problem. Happy Programming!

    • Proposed as answer by Mike FengModerator Wednesday, December 12, 2012 2:44 AM
    • Marked as answer by Rishi90 Thursday, December 13, 2012 9:10 AM
    Monday, December 10, 2012 6:16 AM

All replies

  • Hi,

    from the error it seems that you are providing some wrong parameter say wrong location or wrong file name .

    Can you post file name and location , and what are you providing in the parameter ?


    One good question is equivalent to ten best answers.

    Monday, December 10, 2012 6:03 AM
  • Looks like you have to give the associated program name. For, example, most of the image files can be opened in MSPaint. So, you can change your code as below. If that works, then it means there is no associated program that can open your image file. If it doesn't work, then possibly the image file is corrupted.

    System.Diagnostics.Process.Start("MSPaint.exe", localFilename);

    You can also replace "MSPaint.exe" with any other program name that can open your image file.

    I hope this helps.


    Please mark this post as answer if it solved your problem. Happy Programming!

    • Proposed as answer by Mike FengModerator Wednesday, December 12, 2012 2:44 AM
    • Marked as answer by Rishi90 Thursday, December 13, 2012 9:10 AM
    Monday, December 10, 2012 6:16 AM