File not found or could not be opened for reading

I follow the given sample code.When I am trying to load one module to the real controller , it returns the error : RobotStudio .NET exception:  File not found or could not be opened for reading. However , the  module does exist . Here is  my code , any idea? I am a green hand ,thanks a lot !

private static void button_ExecuteCommandSecond(object sender, ExecuteCommandEventArgs e)
            // Step 1: Connect to the controller
            #region LMStep1
            Guid systemId = new Guid("7fa807ce-c383-42b6-8a32-549fcb4cb50d");
            Controller controller = new Controller(systemId);

            // Clears the eventlogs in the controller

            // Gets the task with the specified name.
            ABB.Robotics.Controllers.RapidDomain.Task tRob1 = controller.Rapid.GetTask("T_ROB1");

            // Step 2: Select module from PC
            #region LMStep2
            if (System.IO.File.Exists(@D:\Temp\MyModule.mod))
                    string ModulefilePath = @D:\Temp\MyModule.mod;
                    bool bLoadModuleSuccess = false;

                    // Step 3: Load Module 
                    #region LMStep3
                    using (Mastership.Request(controller.Rapid))
                        // Loads a RAPID module to the task in the robot controller.
                        Logger.AddMessage("The mastership has been gotten.");
                        bLoadModuleSuccess = tRob1.LoadModuleFromFile(ModulefilePath, RapidLoadMode.Replace);      // According to the report ,here happens the error.


  • Mephisto
    Mephisto Denmark
    Hey hanpeiwen,
    I know it's been a while, but did you ever solve your question above?
    I'm sitting here with what I believe is that same problem. My code closely resembles ABB example for uploading a mod fiel to a controller and it even works on a virtual one.
    But as soon as I try it on a physical controller I'm getting the error file not found.
    Was hoping you or someone else might have some suggestions to what I'm doing wrong.

  • Micky
    Micky Germany ✭✭✭

    I think you have to copy your file to the controller before you can load it from there.
    As I know it is not possible to load a file directly from the PC into the real controller.

    You can use the following method to copy your file:
    aController.FileSystem.PutFile(localFilePath, remoteFilePath);
    See also the following link:

    Best regards

  • DenisFR
    DenisFR FRANCE ✭✭✭
    Physical controller use Unix folder separator '/'.
    Filename could be like this: "HOME:/myfilename.txt".
    Look at Open instruction in RAPID manual.
    You can use RobOS() to know if you're running in virtual or real robot.