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.
Page 1 of 1
Retrive directory on runtime? in C#
#2
Posted 10 October 2008 - 09:59 PM
What kind of images?
#3
Posted 11 October 2008 - 02:14 AM
This is how it works in VB, and yes C# is remarkably similar
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
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 IfIs 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
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
)
Many thanks,
Wolfy87.
erm .png? just things for the background etc.
Many thanks,
Wolfy87.
Romeo29, 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

Help




Back to top









