Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Retrive directory on runtime?


  • Please log in to reply
3 replies to this topic

#1 Wolfy87

Wolfy87

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:11:20 PM

Posted 10 October 2008 - 02:45 PM

I have been looking on google and have tryed vairious methods but none seem to work. is there a simple way of retriving a directory of an image etc for in my program it has images and if it is used on another computer it will proboly be in a different place to mine so is there a simple way?
Thanks,
Wolfy87.

BC AdBot (Login to Remove)

 


#2 Romeo29

Romeo29

    Learning To Bleep


  • Members
  • 3,194 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:127.0.0.1
  • Local time:06:20 PM

Posted 10 October 2008 - 09:59 PM

What kind of images?

#3 PlyPencil

PlyPencil

  • Members
  • 51 posts
  • OFFLINE
  •  
  • Local time:12:20 AM

Posted 11 October 2008 - 02:14 AM

This is how it works in VB, and yes C# is remarkably similar

Dim mypath As String = "C:\" 'PLACE YOUR DIRECTORY HERE, I reccomend my.computer.filesystem.specialdirectories.programfiles.tostring
		' Clear the list box and the picture box.
		Me.ListBox1.Items.Clear()
		Me.PictureBox1.ImageLocation = ""




		' Add each image in the Pictures directory to list box.
		For Each foundImage As String In _
					My.Computer.FileSystem.GetFiles( _
			mypath, _
			FileIO.SearchOption.SearchTopLevelOnly, "oliesimage.jpg", "*.exe*") 'Put either an extension or a file to search here, remember more than 1 can be searched. SearchTopLevelOnly to search 1 folder, SearchAllSubFolders to search all in the program files dir
			Me.textbox1.text = (foundImage) 'add the image firectory
		Next



		If Me.textbox1.text = "" Then 'If no images were found do this
			MsgBox("There are no .exe or oliesimage.jpg images in" _
			& " the Picture folder.")
		End If

Is this what you wanted? the path of the found file is sent to a text box

This is how you would get the picturebox to display the image

Me.PictureBox1.ImageLocation = Me.textbox1.text

Edited by PlyPencil, 11 October 2008 - 02:16 AM.


#4 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:11:20 PM

Posted 13 October 2008 - 11:35 AM

i would like it more direct as in it serches for it and stores it in an array or just says at the end "olliesimage.png".directory = pictureBox1.Image; i know that is nothing like it but its just a rough gess. so if it could search first then in that same process assign the found directory to the image box, that would be perfect otherwise if they save it to an odd location it will through and error (sorry about the spelling :thumbsup:)
Many thanks,
Wolfy87.

What kind of images?

erm .png? just things for the background etc.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users