TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Danie Grey
NA
1
1.3k
delete and upload files in database and images in folder
Jul 10 2012 8:29 PM
Hi, I am currently working on a project where I have to upload images in a folder and upload it's corresponding information like order_number, VehicleID, etc in the database. Can anybody please provide me a code where I could do all of this? Also, how can I delete the images stored in the folder using vb.net code? P.S. I am a new to vb.net programming. Thank you with all the help you can provide.
'the code to delete image in the folder
Private Sub PictureBox11_DoubleClick(sender As System.Object, e As System.EventArgs) Handles PictureBox11.DoubleClick
Try
If imagelocationFromPicboxes(10).Equals(newImagePath(10)) Then
My.Computer.FileSystem.DeleteFile(newImagePath(10))
End If
PictureBox11.Image = Nothing
Catch ex As Exception
End Try
End Sub
'Code where I can save the image in a folder
'I also need to upload the idvehicle, ordernumber idimage in tables in the database
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim i As Integer = 0
Dim counter As Integer = 1
Dim fileName As String
'Dim idVehicle As Integer
Dim newPath As String
i = 0
While i < 25
If Not String.IsNullOrEmpty(imagelocationFromPicboxes(i)) Then
fileName = Path.GetFileName(imagelocationFromPicboxes(i))
newPath = strBasePath + fileName
If File.Exists(newImagePath(counter - 1)) = True Then
My.Computer.FileSystem.DeleteFile(newImagePath(counter - 1))
End If
My.Computer.FileSystem.CopyFile(imagelocationFromPicboxes(i), newPath)
newFileName = "0000000001" + "_00" + counter.ToString() + Path.GetExtension(imagelocationFromPicboxes(i))
My.Computer.FileSystem.RenameFile(newPath, newFileName)
imagelocationFromPicboxes(i) = newImagePath(counter - 1)
counter = counter + 1
End If
i = i + 1
End While
MessageBox.Show("Image/s uploaded!")
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try
Reply
Answers (
0
)
I am having trouble remembering what I did to find out if the cursor.position is within a certain area (region) on a form. Anybody know what to do in this case?
convert vb6 code to vb.net