简体   繁体   中英

C# get the program location / block pop up window

I would like to preempt pop up / error window if the users machine doesn't have required .net framework installed. I was thinking about checking the users registry first with simple "if" statement but will this work? If yes than I would love see some examples.

The second question is about getting the folder which contains my application. Usually it's default location like "downloads" folder or the desktop but what if someone saved it in different place? How to retrieve this location?

You can check the registry to determine which .NET version is installed. See this link for details: https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed

You can NOT do this check in your application, because if .NET is not installed it won't run at all. You can create a simple native application which checks the registry and shows the error message or starts your .NET application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM