This article shows how to transfer files between a PC and a Yaskawa Motoman controller, in C# or Python. It gives a complete program that saves every job of the controller, sends a new job and downloads the CMOS backup.

## Prerequisites

- The SDK is connected to the controller: see [Connect to your robot](/yaskawa/documentation/connect). The file transfers use the UDP port 10041.
- To replace a file, `RS029` and `RS214` are `1`. For the CMOS backup, the automatic backup uses the RAM disk. See [Files and backup](/yaskawa/documentation/hses-files).

## Which method to choose

| Need                                | Method                                                   |
| ----------------------------------- | -------------------------------------------------------- |
| The list of the jobs or data files  | `GetFileList("*.JBI")`                                   |
| A copy of one file                  | `GetFile(name)`                                          |
| A job written or changed on the PC  | `LoadFile(name, content)`                                |
| A complete backup of the controller | `BatchDataBackup()`, then `GetFile("/SPDRV/CMOSBK.BIN")` |
| Remove a file                       | `DeleteFile(name)`                                       |

## Example

**C# : HowToTransferFiles**
```csharp
using UnderAutomation.Yaskawa;
using UnderAutomation.Yaskawa.HighSpeedEServer;

public class HowToTransferFiles
{
    static void Main()
    {
        /**/
        var robot = new YaskawaRobot();
        robot.Connect("192.168.0.1");

        string folder = Directory.CreateDirectory("JobsBackup").FullName;

        // 1. Download every job of the controller
        foreach (string name in robot.HighSpeedEServer.GetFileList("*.JBI").Files)
        {
            RobotFileContentData file = robot.HighSpeedEServer.GetFile(name);
            File.WriteAllText(Path.Combine(folder, name), file.Content);
            Console.WriteLine($"Saved {name}");
        }

        // 2. Send a job written on the PC. RS029 and RS214 must allow the overwrite
        string job = File.ReadAllText("NEWJOB.JBI");
        robot.HighSpeedEServer.LoadFile("NEWJOB.JBI", job);

        // 3. Save the CMOS backup of the controller
        robot.HighSpeedEServer.BatchDataBackup();
        File.WriteAllBytes(Path.Combine(folder, "CMOSBK.BIN"), robot.HighSpeedEServer.GetFile("/SPDRV/CMOSBK.BIN").ContentRaw);

        robot.Disconnect();
        /**/
    }
}
```

**Python : HowToTransferFiles**
```python
import os
from underautomation.yaskawa.yaskawa_robot import YaskawaRobot
from underautomation.yaskawa.connect_parameters import ConnectParameters

##
robot = YaskawaRobot()
robot.connect(ConnectParameters("192.168.0.1"))
hses = robot.high_speed_e_server

folder = "JobsBackup"
os.makedirs(folder, exist_ok=True)

# 1. Download every job of the controller
for name in hses.get_file_list("*.JBI").files:
    file = hses.get_file(name)
    with open(os.path.join(folder, name), "w", newline="") as f:
        f.write(file.content)
    print(f"Saved {name}")

# 2. Send a job written on the PC. RS029 and RS214 must allow the overwrite
with open("NEWJOB.JBI", newline="") as f:
    hses.load_file("NEWJOB.JBI", f.read())

# 3. Save the CMOS backup of the controller
hses.batch_data_backup()
with open(os.path.join(folder, "CMOSBK.BIN"), "wb") as f:
    f.write(bytes(hses.get_file("/SPDRV/CMOSBK.BIN").content_raw))

robot.disconnect()
##
```

The program:

1. downloads each job to the folder `JobsBackup` of the PC;
2. sends the job `NEWJOB.JBI` of the PC to the controller;
3. makes the CMOS backup on the controller and downloads it.

## Version the jobs

The jobs are text files. Save them in a version control system (Git...) after each download: you see what changed on the controller between two backups, and you can send an older version back.

## Troubleshooting

- **`Cannot over write the target file`:** set `RS029` and `RS214` to `1`.
- **The upload of a job is refused with a syntax error:** the controller checks the job when it receives it. Open the job in MotoSim or on the pendant to find the line.
- **The CMOS download fails just after `BatchDataBackup()`:** the backup is still running. Wait a few seconds and download again.
- **A large file fails on a slow network:** increase `FileTimeoutMilliseconds`.

## What to read next

- [Files and backup](/yaskawa/documentation/hses-files): the reference of the file methods.
- [Run a job](/yaskawa/documentation/how-to-run-program).