Getting own filename
-
Yes, of course. OK, here's what I use:
System.Windows.Forms.Application.ExecutablePath
and sometimes I pass that throughSystem.IO.Path.GetFileNameWithoutExtension()
modified on Thursday, January 22, 2009 10:40 PM
-
Yes, of course. OK, here's what I use:
System.Windows.Forms.Application.ExecutablePath
and sometimes I pass that throughSystem.IO.Path.GetFileNameWithoutExtension()
modified on Thursday, January 22, 2009 10:40 PM
PIEBALDconsult wrote:
Yes, of course.
:laugh:
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Individuality is fine, as long as we do it together - F. Burns
-
Get the current process using
Process.GetCurrentProcess()
Then use theProcessName
orMainModule
property.«_Superman_»
-
Get the current process using
Process.GetCurrentProcess()
Then use theProcessName
orMainModule
property.«_Superman_»
I don't think that'll work reliably.
-
I don't think that'll work reliably.
You mean, we would not always get the filename ?
«_Superman_»
-
You mean, we would not always get the filename ?
«_Superman_»
Is there a guarantee that the process name is the filename? On the other hand I just tried it and it seems to be reliable. At least it knows if I change the file name. I may need to look into it further.
-
Is there a guarantee that the process name is the filename? On the other hand I just tried it and it seems to be reliable. At least it knows if I change the file name. I may need to look into it further.
I guess you might as well you the
GetModuleFileName
API«_Superman_»
-
If main calls a library routine in another assembly and that routine does that, you'll get the name of the library assembly, not the assembly containing main.
-
I guess you might as well you the
GetModuleFileName
API«_Superman_»
That may have a problem if called from a different assembly? I guess stick with
System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName
. I suppose mightSystem.Windows.Forms.Application.ExecutablePath
call that.