Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'import library
- Imports System.IO.File
- 'Variable
- Dim FileExtension() As String
- Dim FileAdress As String = Application.StartupPath & "\galeri\default.png"
- Dim FileName() As String
- Dim Destination As String = System.Environment.CurrentDirectory & "\galeri\"
- Dim tmpFileName As String
- 'Button
- Private Sub btnUnggah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUnggah.Click
- 'ofd name komponen open file dialog
- ofd.InitialDirectory = "\"
- ofd.FileName = "NamaFIle"
- ofd.Filter = "Ekstensi Gambar (JPEG,GIF,BMP,PNG,ICO)|*.jpg;*.jpeg;*.gif;*.bmp;*.png;*ico"
- ofd.ShowDialog()
- End Sub
- 'Open File Dialog
- Private Sub ofd_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ofd.FileOk
- tmpFileName = ofd.SafeFileName
- FileAdress = ofd.FileName
- FileExtension = tmpFileName.Split(".")
- pb.Load(ofd.FileName)
- End Sub
- 'Pas disimpen
- If System.IO.Directory.Exists(Destination) Then 'jika direktori maka memilih ini
- If System.IO.File.Exists(Destination & txtUname.Text.Replace("'", "'") & ".jpg") Then
- MsgBox("File Foto Sudah Ada", MsgBoxStyle.Information)
- Else
- System.IO.File.Copy(FileAdress, Destination & txtUname.Text.Replace("'", "'") & ".jpg")
- End If
- Else
- System.IO.Directory.CreateDirectory(Destination) 'membuat direktori jika tidak ada
- If System.IO.File.Exists(Destination & txtUname.Text.Replace("'", "'") & ".jpg") Then
- MsgBox("File Foto Sudah Ada", MsgBoxStyle.Information)
- Else
- System.IO.File.Copy(FileAdress, Destination & txtUname.Text.Replace("'", "'") & ".jpg")
- End If
- End If
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement