none
opening a file with an APP exe! RRS feed

  • Question

  • Hello, i have spent the last couple of months developing a small app based on reading and writing to a RichtextBox. When the user clicks the run button, it will take the saved file and then open it with the appropriate application.
    This application is installed on the hard drive.
    the problem is that the application has just been given an update and is now a stand-alone app within an exe file.
    Where as before my app would open the file correctly and directly i am now seeing that my file opens the new app but wont display the results.

    lets say i am saving as a .txt file and then run opens wordpad.
    Imagine that word pad got an update is no longer installed and just sits ther as an exe file waiting. My saved file will open word pad but won't display the info.

    if anyone has any ideas or suggestions then i am all ears.

    Is that clear enough? Even i'm not sure if i understand myself :D

    Thanks in advance.

    regards Flatland France


    • Edited by EyeMan Android Wednesday, June 28, 2017 11:39 AM forgot something
    Wednesday, June 28, 2017 11:37 AM

Answers

  • Hi Acamar,
    Thankyou for your time, our main app is still in beta, but has now been modified and my own App now works as it should.

    Cheers


    regards Flatland France

    Thursday, June 29, 2017 12:21 PM

All replies

  • lets say i am saving as a .txt file and then run opens wordpad.

    Do you mean "... and then clicking the 'run' button opens wordpad"?  Show the code that you are using to do this.  

    You should also explain what you mean by "a stand-alone app within an exe file" because your description implies that it always was a stand-alone app, so it's not clear what has changed.

    Wednesday, June 28, 2017 12:01 PM
  • Hi
    This is the code:
        Private Sub RunToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles RunToolStripMenuItem.Click
            If OpenedFilename <> "" Then
    
                Process.Start(OpenedFilename)
            Else
                MsgBox("File Does Not Exist")
            End If
        End Sub
    Where as before the program needed to be installed to work, the new version is just an exe file it no longer needs to be installed.

    You can learn more here about the app i am trying to open with my file.
    https://www.facebook.com/groups/730345180388776/


    regards Flatland France

    Wednesday, June 28, 2017 12:35 PM
  • Where as before the program needed to be installed to work, the new version is just an exe file it no longer needs to be installed.

    You are starting an app using a filename.  Therefore, the app that gets started depends on the association that has been set up for the filename extension.  For instance, if the line of code is executed as
                Process.Start("sample.txt")

    then whatever application is associated with the extension 'txt' will be executed.

    But what happens when that app is executed depends on settings within Windows.  It might be that the filename is passed to the app (which seems to be what was happening before) or perhaps it isn't passed to the app (which might be what is happening now).  Or perhaps the app needs some other argument, like an instruction as to whether the file should be opened or printed or something else, and if it doesn't get that instruction it does nothing.   

    That's the risk you take when you start an application by using a filename - what happens depends entirely on how the application that is getting started has been set up with its filename extension association.  I think your comment "... is just an exe file it no longer needs to be installed" means that no particular file association is being set up for this app.

    A much better procedure is to start the app using the exact command line that the app expects, for the task that you want it to do.  The simplest case would be

                Process.Start("Wordpad.exe sample.txt")

    to open wordpad and open the file.  When you do it like that you can construct that command so it is in the exact format that the app needs to do exactly what you want it to do.  

    You need to find out what command line that other app requires in order to open a file where the filename is passed to the app as part of the command line, and then construct your command line to provide exactly that command.

    • Proposed as answer by Frank L. Smith Wednesday, June 28, 2017 1:44 PM
    Wednesday, June 28, 2017 1:08 PM
  • I understand what you are saying, but i can't give anything a name because if the user creates a new file, it will change.
    And yes it is the file extension that is calling on the app. It opens the new version but won't display.

    I will check with the main app developer and see what he says.

    Thanks for your time, it is appreciated.

    regards Flatland France

    Wednesday, June 28, 2017 1:37 PM
  • I understand what you are saying, but i can't give anything a name because if the user creates a new file, it will change.

    You are allowing for the different filenames by using a variable: 'OpenedFilename'.  That will stay the same.  The change you need to make is to create a complete command line - using that filename variable - so that you exactly specify what you want to happen, instead of relying on the default action for the extension.

    Wednesday, June 28, 2017 10:14 PM
  • Hi Acamar,
    Thankyou for your time, our main app is still in beta, but has now been modified and my own App now works as it should.

    Cheers


    regards Flatland France

    Thursday, June 29, 2017 12:21 PM
  • Hi Acamar,
    Thankyou for your time, our main app is still in beta, but has now been modified and my own App now works as it should.

    Cheers


    regards Flatland France

    Will you than be so kind to mark all replies which helped you to get that mark as answer?

    (Acamar is probably now sleeping)


    Success
    Cor

    Thursday, June 29, 2017 12:23 PM