Move File

From SwiftAPI

Jump to: navigation, search

Contents

C#

msdn

System.IO.File : public static void Move(
    string sourceFileName,
    string destFileName
)
using System.IO;
 
string source = "file.txt";
string dest = "file2.txt";
File.Move(source, dest);

Perl

use File::Copy;
$source = 'file.txt';
$dest = 'file2.txt';
move($source, $dest);

PHP

php.net

bool rename ( string $oldname , string $newname [, resource $context ] )
$source = 'file.txt';
$dest = 'file2.txt';
rename($source, $dest);

Python

docs.python.org

import os
source = 'file.txt'
dest = 'file2.txt'
os.rename(source, dest)

This version also works across filesystems:

docs.python.org

import shutil
source = 'file.txt'
dest = 'file2.txt'
shutil.move(source, dest)

Ruby

require 'ftools'
source = 'file.txt'
dest = 'file2.txt'
File.move(source, dest)
Personal tools