BleepingComputer.com: Retrive directory on runtime?

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Retrive directory on runtime? in C#

#1 User is offline   Wolfy87 

  • Senior Member
  • PipPipPipPip
  • Find Topics
  • Group: Members
  • Posts: 414
  • Joined: 25-July 08
  • Gender:Male
  • Location:England

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.

#2 User is offline   Romeo29 

  • Learning To Bleep
  • PipPipPipPipPipPip
  • Find Topics
  • Group: BC Advisor
  • Posts: 2,834
  • Joined: 06-July 08
  • Gender:Not Telling
  • Location:127.0.0.1

Posted 10 October 2008 - 09:59 PM


#3 User is offline   PlyPencil 

  • Member
  • PipPip
  • Find Topics
  • Group: Members
  • Posts: 51
  • Joined: 26-September 08

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

This post has been edited by PlyPencil: 11 October 2008 - 02:16 AM


#4 User is offline   Wolfy87 

  • Senior Member
  • PipPipPipPip
  • Find Topics
  • Group: Members
  • Posts: 414
  • Joined: 25-July 08
  • Gender:Male
  • Location:England

  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.

View PostRomeo29, on Oct 11 2008, 03:59 AM, said:

What kind of images?

erm .png? just things for the background etc.

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users