Hi all, I'm a newbie so please forgive me if i mess this up :-)
I am working on a new vb app in vb 2008 that works of a database. What i want to do is store a short image path to the database field (the picture is displayed on a vb form.)
Anyway, i can get the full path of the picture but i want to crop it to just everything AFTER the appication.startuppath, IE:
I get image path as: C:\Users\me\Documents\Visual Studio 2008\Projects\mydbapp\picture\local\image1.jpg
I then store this in a textbox, now i want to retrieve everything EXCEPT the application path which in this case is 'C:\Users\me\Documents\Visual Studio 2008\Projects\mydbapp' so i just get
'picture\local\image1.jpg'
The application path will change once it is rolled out hence i just store the short image path in the db and manually add application.startuppath in code so as it will always work (in theory!!)
PLEASE HELP ME ASAP, i have googled all day and not been able to solve it.
Many thanks in anticipation of your answer
Loading
s cPosted Jul 8, 2008, 4:11 PM
Many thanks for your help in solving this for me, i owe you a drink :-)
AlanPosted Jul 8, 2008, 3:55 PM
Try:
Dim fullPath As String = "C:\Users\me\Documents\Visual Studio 2008\Projects\mydbapp\picture\local\image1.jpg"
Dim trimmedPath = ""
If (fullPath.StartsWith(Application.StartupPath))
Dim index As Integer = Application.StartupPath.Length + 1
trimmedPath = fullPath.Substring(index)
Else
trimmedPath = fullPath
End If
MessageBox.Show(trimmedPath)