When you're developing the webapp returns the path to the project on your local computer because your computer is the web server, all be it a fake one, but one nonetheless. This is why you don't have an Application.StartupPath, because if you did, it's the location on the web server, not the person's local machine who's viewing your site in their web browser. Why does my Big Fat Visual Basic 2008 book explicitly say that I can use My.Application, but Intellisense in Visual Studio 2008 doesn't recognize it?WebApp's don't have access to the local system like WinForm's apps do. It is extraordinary that it takes this much effort to find this out. Why does my Big Fat Visual Basic 2008 book explicitly say that I can use My.Application, but Intellisense in Visual Studio 2008 doesn't recognize it? Is this one right? If I use that, can I (somehow) package my little executable with my web application and run it from that directory? And if the answer to that is yes, is there some magic to putting that executable in that directory? Location() gives C:\Users\username\AppData\Local\Temp\Temporary ASP.NET Files\root\fe508d91\60a8c65a\assembly\dl3\b72b7ebd\60f25a6c_b1c2ca01\WebApplication2.DLL at runtime, so that's not it either.Ī gives C:\Users\username\Documents\Visual Studio 2008\Projects\WebApplication2\WebApplication2\ at runtime in my development environment, and that seems to hold the most promise. Likewise, if I type "Application.s" into the editor, it gives me "Set" and "StaticObjects" as options, but no "Startup" or "Startup()".Įnvironment.CurrentDirectory gives C:\Windows\system32 at runtime in my development environment that's not it. If I type "My." into my Visual Studio editor, for instance, it gives me Computer and User, but not Application, as options, so I gather I cannot use My.Application for anything. Many of the answers given in this thread and other places so far don't seem to fit my environment.
VB NET 2010 GET STARTUP PATH HOW TO
It would seem to make sense to put it in the same place as the EXE and DLL files containing the web application, but I don't know how to access it after that. I want to execute an external program to perform a function for the user, so I need to put the executable somewhere that is independent of its installation machine and accessible by my code. NET web application in visual studio 2008. This is an interesting thread, not least because of all the effort put in so far that still doesn't answer my particular question. net newbie, though experienced in other languages and technologies. String pathToExecutable = Environment.GetCommandLineArgs().Replace(".dll", ".I'm a relative Visual Studio/VB. But after you publish it, you'll get the exe. Before you package the app as a single file bundle, you will get the dll. String basedir = AppContext.BaseDirectory Best I got now is: // This will give you the directory but not the assembly None of the above work if using net5.0 or net6.0 and publishing app as single-file bundle. Uri.UnescapeDataString((New System.UriBuilder(.CodeBase).Path)) Path.GetDirectoryName(Uri.UnescapeDataString((New System.UriBuilder(.CodeBase).Path)))
VB NET 2010 GET STARTUP PATH CODE
The code for each is below the image using fully qualified names.
Unfortunately I can't figure out how to create a table here, so it's an image. This is the first post on google so I thought I'd post different ways that are available and how they compare.