d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Beginner Question
12Next
Add Reply New Topic New Poll
Member
Posts: 6,175
Joined: Sep 4 2009
Gold: Locked
Trader: Scammer
Sep 28 2014 07:38pm
How do I save a photo so that when using picture box, it would allow users from any computer to view the photo

At the moment, the photo will only show up on my computer because I saved it to my desktop :

pictureBox1.ImageLocation = (@"C:\Users\Jwang\Desktop\Jwang.jpg");

How do I make it so that when i send it in, the marker would be able to view the photo without changing the destination of the photo?

Thanks
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Sep 28 2014 07:44pm
is this C# I am guessing?

I feel like you left out quite a few details o.o

Normally for a desktop application I would imagine you have a /resources folder (somewhere under the root dir for your app) where you would store imgs....(obviously, the users would have to have this resources folder as well on their machine)

edit: quick google search:

Quote
The property value can be an actual path (for example, “C:\SomeFolder\SomeSubFolder\Picture.jpg”), a relative path (“\SomeSubFolder\Picture.jpg”), or a URL (http://contoso.com/images/Picture.jpg).
If a relative path is used, it will be considered relative to the working directory.
A call to the Load method will overwrite the ImageLocation property, setting ImageLocation to the URL value specified in the method call.


so you could use a URL

This post was edited by Eep on Sep 28 2014 07:51pm
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Sep 28 2014 07:51pm
i'm not familiar with your @ sign for strings except in objective c.

but to answer your question, two options:
1) if user creates/saves the image from your app, then you have a path. just save that path and use it.
2) if it comes packaged with the app, then you just specificy the path relative to current dir. eg: "resources/Jwang.jpg" or "../resources/Jwang.jpg"
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Sep 28 2014 09:34pm
Quote (carteblanche @ Sep 28 2014 08:51pm)
i'm not familiar with your @ sign for strings except in objective c.


In C# if you prefix a string literal with the @ symbol it means the string is to be read literally. It allows you to write out string literals without escaping special characters.

this

Code
string a = @"C:\Users\Minko";


if equivalent to this

Code
string b = "C:\\Users\\Minko";



In Objective-C, prefixing a literal with the @ makes it evaluate to a pointer.
Member
Posts: 6,175
Joined: Sep 4 2009
Gold: Locked
Trader: Scammer
Sep 28 2014 09:42pm
Sorry for not being detailed at the start, but I am using visual basics for windows desktop and its C#
Member
Posts: 6,175
Joined: Sep 4 2009
Gold: Locked
Trader: Scammer
Sep 28 2014 09:46pm
Quote (carteblanche @ Sep 28 2014 05:51pm)
i'm not familiar with your @ sign for strings except in objective c.

but to answer your question, two options:
1) if user creates/saves the image from your app, then you have a path. just save that path and use it.
2) if it comes packaged with the app, then you just specificy the path relative to current dir. eg: "resources/Jwang.jpg" or "../resources/Jwang.jpg"


User (Marker) will extract my files from a compressed zip folder that I will hand in online. So all the resources required will be in the folder (pictures, application)



This post was edited by Chesse on Sep 28 2014 09:46pm
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Sep 28 2014 09:50pm
Quote (Minkomonster @ Sep 28 2014 11:34pm)
In C# if you prefix a string literal with the @ symbol it means the string is to be read literally. It allows you to write out string literals without escaping special characters.

this

Code
string a = @"C:\Users\Minko";


if equivalent to this

Code
string b = "C:\\Users\\Minko";



In Objective-C, prefixing a literal with the @ makes it evaluate to a pointer.


now that you mention it, i remember reading that a while back. i've never actually used it. bad java hobbits D:
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Sep 28 2014 10:41pm
Quote (Chesse @ Sep 28 2014 11:46pm)
User (Marker) will extract my files from a compressed zip folder that I will hand in online. So all the resources required will be in the folder (pictures, application)


Look for a C# function to find your current running directory, and then append your logical path to your images there. Another option would be to store your image as a byte array inside your project and have it load it from memory.

Here is the function you are looking for. More information can be found in the msdn.

Code
public static string GetCurrentDirectory()


This post was edited by AbDuCt on Sep 28 2014 10:43pm
Member
Posts: 6,175
Joined: Sep 4 2009
Gold: Locked
Trader: Scammer
Sep 28 2014 10:47pm
Thanks guys, I'm just going to write a comment telling the marker to change the directory of my account to the current one they are using. I am on my third week so I doubt they will be strict on the picturebox rule.

Another question:

Is there a way to get modeling project: use cases for microsoft visual basics express for windows desktop?
I don't have the option on my application and was hoping if theres a way to download it
Member
Posts: 2,757
Joined: Nov 26 2007
Gold: 1,214.81
Sep 29 2014 07:30am
Why you guys make this seem so complicated? Just put the picture in the bin folder and use relative directory.

pictureBox1.ImageLocation = ("Jwang.jpg");
Go Back To Programming & Development Topic List
12Next
Add Reply New Topic New Poll