Get the form's executable path

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 10 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
clum09
Posts: 150
Last visit: Sun Jan 21, 2024 5:07 pm

Get the form's executable path

Post by clum09 »

Hello,

Is there any way I can get the form's executable path?

I tried to use the following code, but it does not work.

[System.Windows.Forms.Application.StartupPath]

There may an assembly that I need to load, but I don't know how.

Thanks.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Get the form's executable path

Post by davidc »

There is a code snippet called getscriptdirectory which inserts a function that will give you the path of the script or packaged exe.

You can also find this function in the Global.ps1 of a Form project.

Correction to your code. It should be:
PowerShell Code
Double-click the code block to select all.
[System.Windows.Forms.Application]::StartupPath
Note: This should also work in form exe.

David
David
SAPIEN Technologies, Inc.
User avatar
clum09
Posts: 150
Last visit: Sun Jan 21, 2024 5:07 pm

Re: Get the form's executable path

Post by clum09 »

Davidc,

Thank you for the information. I also found this out myself after I had posted this message.

I just had to use the static method to get the StartupPath of the form's executable file path.

Thanks again.
This topic is 10 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.