It sounds like you are developing a DLL for use by other developers. It also sounds as if you are attempting to create temporary files where you do not know and/or have no control over the environment.
If the above is true, it might be better to create a config file (located in the same directory as your DLL) which contains, among anything else, a path for use with temporary files. (Or, even better, make use of the AppSettings in your App.Config or Web.Config similar to Log4Net)
Absent this config file, you could attempt to use GetTempPath()
, but this will likely fail for ASP.NET (and may fail under other circumstances).
If you fail to create temp files, you could try to store the information you need in memory (using MemoryStream, for example).
If that fails, then you can always tell the user to use the config file.
In answer to your actual question, I am not aware of a way to reliably say what kind of project you are working with. The beauty of .NET is that is so flexible. You could, in theory, write a Console application capable of running as a web server or as a desktop app or as a windows service. It could be all three in one.
You could always try to guess based on the referenced assemblies of the calling executable (System.Windows probably means desktop, System.Web probably means ASP.NET, etc), but that is going to be fraught with error. I have written several desktop applications which reference web assemblies, and I've written web sites that reference desktop assemblies.
But, if you put the path in your config file, then you might not need to know the context... you'll already have the fully qualified path you need without needing to use either GetFullPath() or MapPath().
If you really need to differentiate, you could include a setting in your config file. The user of your DLL would be able to configure the assembly to the environment in which it is being used. If they get the configuration wrong... well... most software will malfunction if you get the configuration wrong. That's the way it goes.
Or... even better... if the behavior of certain tasks (such as finding the path of a file) needs to change based on some condition unknown during development, then you could code your DLL to support dependency injection to enable your user to supply the proper functionality where required.