Application.StartupPath doesn't work?

Ljuslykta

Member
Joined
Mar 9, 2010
Messages
9
Programming Experience
3-5
Hi.

I've almost finished a binary clock, but I have one problem. The user should choose between two different backgrounds, named binary.jpg and binary 1600.jpg

Dim Bild1 As New Bitmap(Application.StartupPath & "/Bilder/binary1600.jpg")
Picturebox1.Image=Bild1


I get "Parameter is not valid" on the first line.

What is wrong, and how should I solve it?
 
No, when i get the startuppath and isert it in the sting it looks like

VB.NET:
 Dim Bild2 As New Bitmap("C:\Documents and Settings\Pontus\Mina dokument\Visual Studio 2005\Projects\Binary_Clock\Binary_Clock\bin\Debug\Bilder\binary1600.jpg")

But I still get "Parameter is not valid"
 
I've already tried with a file that I used in another project. In the beginning, I used App.Startuppath, but then I changed then.
 
Does this path actually exist "C:\Documents and Settings\Pontus\Mina dokument\Visual Studio 2005\Projects\Binary_Clock\Binary_Clock\bin\Debug\Bilder" ? or is the path actually this: "C:\Documents and Settings\Pontus\Mina dokument\Visual Studio 2005\Projects\Binary_Clock\Binary_Clock\Bilder" (without the bin\Debug\ part) ?
 
I would do the opposite, I would set the 'Copy to Output Directory' property to 'Copy if newer' for each item in that folder in your Solution Explorer. Then use Application.StartupPath as normal from there.
 
If I took
Dim Bild1 As New Bitmap("C:\Documents and Settings\Pontus\Mina dokument\Visual Studio 2005\Projects\Binary_Clock\Binary_Clock\bin\Debug\Bilder\binary1600.jpg")
it worked, but if I took
Dim Bild1 As New Bitmap(Application.StartupPath & "Bilder\binary1600.jpg")
, it didn't work
 
If I took
it worked, but if I took , it didn't work
Of course, because Application.StartupPath returns this string:
VB.NET:
C:\Documents and Settings\Pontus\Mina dokument\Visual Studio 2005\Projects\Binary_Clock\Binary_Clock\bin\Debug\
and the "Bilder" doesn't exist in that bin\Debug location.

Have you set the Copy output property in your solution explorer?
 
Back
Top