Monday, January 17, 2011

Rename File Atau Folder

Hai... Ini ada sedikit Source Code untuk Rename File Folder, Posting ini termotivasi dari Pertanyaan Anggota Grup Programer VB Indonesia.
Langsung saja ini codenya, Semoga bermanfaat.


Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Private Type SHFILEOPSTRUCT
    hwnd As Long
    wFunc As Long
    pFrom As String
    pTo As String
    fFlags As Integer
    fAborted As Boolean
    hNameMaps As Long
    sProgress As String
End Type
 Const FO_DELETE = &H3
 Const FO_RENAME = &H4
 Const FO_COPY = &H2

Sub RenameFile()
Dim NewFileName As String
Dim TitleFile
Dim PathFile
'On Error Resume Next
TitleFile = "Baru"
PathFile = "D:\Lama"
NewFileName = InputBox("Are you sure want rename File " & """" & TitleFile & """?", _
        "Rename File", PathFile)
Dim SHDirOp As SHFILEOPSTRUCT
    With SHDirOp
        .wFunc = FO_RENAME
        .pFrom = "D:\BARU"
        .pTo = NewFileName
    End With
SHFileOperation SHDirOp
End Sub

Private Sub Form_Load()
    RenameFile
End Sub
 

6 comments:

  1. terima kasih agan atas sharenya

    ReplyDelete
  2. Oke, Terimakasih kembali Mas Rai..

    ReplyDelete
  3. ngomong" perlu apa aja tuhh..??
    contoh:command button, textbox, dll

    ReplyDelete
  4. @Kocak: Ngga perlu apa" tapi mau dimasukan ke command button atau event lainnya juga bisa hehehe... pertanyaannya kocak ^_^

    ReplyDelete
  5. terima kasih banyak,,,
    informasinya sangat berguna buat saya yang baru belajar visual basic,,,

    ReplyDelete
  6. makasih vbasiccode buat source code nya hehe...

    ReplyDelete