By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,515 Members | 1,042 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,515 IT Pros & Developers. It's quick & easy.

Application.StartupPath not working in VS2005 (worked in VS2003)

P: n/a
I had some code to build the name of a file:
' Build the name of the XML config file.
g_strFiles.strConfig =
My.Computer.FileSystem.CombinePath(Application.Sta rtupPath,
"\Settings\Config main.xml")
This worked fine in Visual Studio 2003. But now that I updated to
VS2005, it no longer works. The Application.StartupPath apparently
seems OK in the editor (no syntax errors and I'm able to select
StartupPath from the Intellisense pop up menu), however when it goes to
run, I get a runtime error:
"StartupPath is not a member of MyApplication"
Where on earth is it getting "MyApplication" -- I didn't have that
word in my line of code. I have Application but not MyApplication.
Indeed, MyApplicattion won't even bring up the Intellisense.
If I do something slightly different, My.Application., it brings up
Intellisense but doesn't have the StartupPath property. How can I get
it to do what you would intuitively want it to do, and why did it work
in VS2003 but not with vs2005?

Mar 27 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Actually, that wasn't necessarily an error, it just had a black
exclamation point in a red circle when I stopped there in the debugger
but it didn't throw an exception. But the result is
g_strFiles.strConfig = "D:\Settings\Config main.xml"
as if the startup path was merely the drive's root folder and not the
actual startup folder. It should have been something like
"D:\MyAppFolder\Settings\Config main.xml" Why is it not getting the
full folder? (Again, it was no problem for VS2003.)

Mar 27 '06 #2

P: n/a

<ha******@hotmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
Actually, that wasn't necessarily an error, it just had a black
exclamation point in a red circle when I stopped there in the debugger
but it didn't throw an exception. But the result is
g_strFiles.strConfig = "D:\Settings\Config main.xml"
as if the startup path was merely the drive's root folder and not the
actual startup folder. It should have been something like
"D:\MyAppFolder\Settings\Config main.xml" Why is it not getting the
full folder? (Again, it was no problem for VS2003.)


Do you have the right 'Imports' set?

Mar 27 '06 #3

P: n/a
Actually I was using the FileSystemObject in VS2003 since it didn't
have the My.Computer namespace yet. I was using something like
g_fsoFile.BuildPath(folder, basefilename)
Then I converted to the My.Computer.FileSystem.CombinePath way which is
the replacement.
If I do
dim folder as string = Application.StartupPath
it give the correct path but even if I pass it in, it seems to strip
off the folder and jsut give the drive.
I.e.
dim folder as string = Application.StartupPath
g_strFiles.strConfig =
My.Computer.FileSystem.CombinePath(folder,
"\Settings\Config main.xml")
still gives "D:\Settings\Config main.xml" instead of
"D:\MyAppFolder\Settings\Config main.xml"
I have Inherits System.Windows.Forms.Form at the top of the module.
I'm not sure what else I need. Generally I don't use Imports
preferring to just use the lengthy but explicit full namespace. I know
it's longer but I don't have to worry about where it's at since I can
see the full thing unlike with Imports where I think you see only the
last few parts.

Mar 27 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.