Older Version
Newer Version
Alyce
Jul 19, 2011
- "changed several instances of kernel132 to kernel32"
Alyce
Jul 19, 2011
- "changed several instances of kernel132 to kernel32"
Copying, Moving, Deleting and Renaming Files
-Table of Contents
Copying a file
Below the method by which a file can be copied using API calls is shown:The currentfilename$ is the string that contains the name of the file you want to make a copy of. The copyfilename$ is the file name for the copy. The bFailIfExists tells the computer what to do if the file name for the copy is already used. If set to 0 the copy will overwrite the current file with the same name. If set to 1 the copy does not overwrite the file. The code below shows how to copy a file into a different folder with the same file name:
The code below shows how to make a copy of a file into the same folder with a different filename:
Remember to include the complete path in the filename.
Moving a file
There are two ways to move a file; using the name command and using API calls.Below the method by which a file can be moved using API calls is shown:
The currentfilename$ is the string that contains the name of the file you want to move. The movefilename$ is the file name for the new location of the file. If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.Points to a null-terminated string that specifies the new name of a file or directory. The new name must not already exist. A new file may be on a different file system or drive. The code below shows how to move a file and keep the same file name.
The code below shows how to move a file with a different file name:
Below the method by which a file can be moved using the name comand is shown:
You must set the filename$ string to the current name of the file you want to move. Remember to include the full path. Then you need to set the movefilename$ to the path to which you want to move it, plus the filename. movefilename$ can be any valid filename as long as it doesn't specify a file that already exists.
A working example is shown below:
Deleting a file
Files can be deleted using the kill command. The kill comand does not place the file in the recycle bin. The code below shows how the kill command works.Use the code above wisely and don't just delete any odd file because it is hard to get it back.
Renaming a file
You can use the name command to rename a file. This command can also be used to move a file. See the move section above to learn how that works. The code below shows how to rename a file:Remember to include file extensions such as .txt on the end of the new file name.
Article by Alex Barfoot
alexbarfoot at gmail.com
-
Table of Contents