Results 1 to 2 of 2

Thread: Moving files...simple app

  1. #1

    Thread Starter
    Frenzied Member dinosaur_uk's Avatar
    Join Date
    Sep 2004
    Location
    Jurassic Park
    Posts
    1,098

    Moving files...simple app

    Hi there,

    I am trying to create a program which will create a desired diretcory name, then move all the jpg files from the program directory to the new directory,...

    this is what i have done so far....

    I can seem to get it to work...please help ....

    Dino

    VB Code:
    1. Dim strFileName As String
    2.  
    3.  
    4.     Private Sub btnMove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMove.Click
    5.         strFileName = txtFile.Text
    6.         IO.Directory.CreateDirectory(strFileName)
    7.         IO.File.Move("*.jpg", Application.StartupPath & "\" & strFileName)
    8.  
    9.         IO.Directory.GetFiles(Application.StartupPath, "*.jpg")
    10.  
    11.     End Sub

  2. #2
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    Hey, this should work for you:
    VB Code:
    1. Private strFileName As String
    2.     Private Sub btnMove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMove.Click
    3.         strFileName = txtFile.Text
    4.             Dim di As DirectoryInfo = New DirectoryInfo(Application.StartupPath)
    5.             For Each fi As FileInfo In di.GetFileSystemInfos("*.jpg")
    6.                 fi.MoveTo("C:\Temp\" & fi.Name)
    7.             Next
    8.     End Sub
    Whadayamean it doesn't work....
    It works fine on my machine!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width