1
@"F:\LEAFPRODUCT\Bin\Service.exe"

This is the physical path of Service.exe, let me know is there any other alternate way or any general way to find the physical path of WrmService.exe in window application.

In a web application we can use Server.MapPath like that. Here I need to reduce path means

label1.Text = AssemblyName.GetAssemblyName(@"F:\LEAFPRODUCT\Bin\Service.exe").Version.ToString();

This is my coding I need to reduce the physical path here, means I don't want to put all the folders I need this way only

label1.Text = AssemblyName.GetAssemblyName("WrmService.exe").Version.ToString();

means only the required file name here means WrmService.exe

orip
  • 73,323
  • 21
  • 116
  • 148
peter
  • 8,158
  • 21
  • 66
  • 119

3 Answers3

8

System.IO.Path.GetFullPath() is similar as Server.MapPath()

You can give it a relative location, and it will give you the full location based on the directory that the assembly is in.

David Basarab
  • 72,212
  • 42
  • 129
  • 156
  • 1
    means label1.Text = AssemblyName.GetAssemblyName(@"F:\LEAFPRODUCT\Bin\Service.exe").Version.ToString(); this is my coding i need to reduce the physical path here ,,means i dont want to put all folders i need this way only label1.Text = AssemblyName.GetAssemblyName("WrmService.exe").Version.ToString(); means only the required file name here means WrmService.exe – peter Sep 08 '09 at 12:51
  • here relative location means? – peter Sep 09 '09 at 06:40
  • ..\SomeFolder\Bin\Some.exe will translate into C:\Code\SomeFolder\Bin\Some.exe like Server.MapPath will take ~\Some.exe into C:\Code\SomeFolder\Bin\Some.exe – David Basarab Sep 09 '09 at 12:35
0

Are you looking for something like this?

Community
  • 1
  • 1
dtb
  • 213,145
  • 36
  • 401
  • 431
0

You want the physical path of the executable assembly?

System.Reflection.Assembly.GetEntryAssembly().Location
Mehrdad Afshari
  • 414,610
  • 91
  • 852
  • 789