app path stopped working
Hi All,
I have :
GetExecutingAssembly.GetName.Name
Which was returning the application path.
Now for some reason it's returning windows\system32 ??
# 1 Re: app path stopped working
GetExecutingAssembly.GetName.Name
This should return the name of the Assembly.
Now for some reason it's returning windows\system32 ?? Either the folder oesn't exist or the way you are trying to access the file is not correct.
A code snippet would be helpful.
# 2 Re: app path stopped working
Dim objXML As DataSet
objXML = New DataSet
objXML.ReadXml(String.Concat(GetExecutingAssembly.GetName.Name, ".xml"))
I'm trying to load my XML file and it's in the app path.
the exception shows that it's trying to get the file at
c:\windows\system32\ypprocess.xml
I'm running from
c:\work\YPprocess
and expect to see c:\work\YPprocess\ypprocess.xml
# 3 Re: app path stopped working
Bill Crawley,
Application.StartupPath does not work?
# 4 Re: app path stopped working
sorry DeepButi,
I dont understand your answer. there isn't an application.startuppath is there??
# 5 Re: app path stopped working
HereobjXML.ReadXml(String.Concat(GetExecutingAssembly.GetName.Name, ".xml")) You are just passing the name of the assembly and not the whole path, So your application looks up for the file in System32 folder. And as the file doesn't exist there so you are getting this error.
Try this instead
objXML.ReadXML(String.Concat(Application.StartupPath, "\", System.Reflection.Assembly.GetExecutingAssembly.GetName.Name, ".xml"))
# 6 Re: app path stopped working
it say application doesn't exist.
I had the original declaration in a standard class project, Now I'm using a class in an asp.net project
# 7 Re: app path stopped working
it say application doesn't exist.
I had the original declaration in a standard class project, Now I'm using a class in an asp.net project
oops.. if it is an ASP.NET application, then Application.Path won't be present there.
# 8 Re: app path stopped working
thought I might be able to use System.IO.Directory.GetCurrentDirectory but that seems to be empty
# 9 Re: app path stopped working
Did you try using System.Reflection.Assembly.GetExecutingAssembly.GetExecutingAssembly.Location
# 10 Re: app path stopped working
using this i get
"Could not find file "c:\windows\microsoft.net\framework\v1.1.4322\temporary asp.net files\ypprocess\52e39826\42a464b0\assembly\dl2\3744c7a8\9e7dc7f4_b1c9c501\ypprocess.xml"."
# 11 Re: app path stopped working
ok,
Have found the answer with the aid of another site.
in the global.asax.vb file declare a public shared variable, then in the session.start set the variable to the request.PhysicalApplicationPath
THen in the class just use this variable and it works.
# 12 Re: app path stopped working
You could also use this
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase)