Results 1 to 6 of 6

Thread: EASY! HELP! HELP! Move and Rename a file

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    71

    Cool

    I have an application that opens a text file that it recieves daily via ftp. It appends all of the data in the text file to a SQL7 db and then closes the db connection. I then need the program to move the file to a different folder and rename it with a new file name. What code can I use to handle the moving and renaming?

  2. #2
    Addicted Member matbrophy's Avatar
    Join Date
    Sep 1999
    Location
    Kent, United Kingdom
    Posts
    149

    Thumbs up Answer

    Very easy

    FileCopy "Drive:\folder\file.ext", "NewDrive:\folder\newfile.ext"

    You can use that to copy the file, it will also rename it if you type a different filename.

    But, so you know to rename a file use:

    Name "oldfilename.ext" As "newfilename.ext"

    Matthew

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    71

    How could I then delete the old file?

    How could I then delete the old file as it can not exist when a file with the same name is ftped to the directory again the next day?

  4. #4
    Lively Member
    Join Date
    Feb 2000
    Posts
    120
    kill "c:\ffff.txt
    shachar shaty

  5. #5
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Worldwide in the Sun
    Posts
    566
    Originally posted by VBDever
    I have an application that opens a text file that it recieves daily via ftp. It appends all of the data in the text file to a SQL7 db and then closes the db connection. I then need the program to move the file to a different folder and rename it with a new file name. What code can I use to handle the moving and renaming?
    Hi,

    There is a FileCopy Statement.

    Syntax: FileCopy source, destination

    source : Rquired. STRING Expression specifies the name of the file to be copied. May include directory or folder, and drive.

    destination: Required. String Expression specifies the target file name. May include directory, folder, and drive.

    Remarks.
    If you try to use the FileCopy statement on a currently open
    file, an error occurs.

    EXAMPLE
    [code]
    Dim SourceFile, DestinationFile

    SourceFile = "C:\TEMP\SRCFILE"
    DestinationFile= "C:\TEMP2\DESTFILE"

    FileCopy SourceFile,DestinationFile

    Cheers
    ray
    Ray

  6. #6
    Lively Member
    Join Date
    Feb 2000
    Posts
    120
    sorry

    kill "c:\tttt.txt"

    it deletes the file perfectly

    good luck
    shachar shaty

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