RobotStudio event

SaveToFile Not successful

Hi :

I have a problem about Module savetofile .When I connected to the real IRC5 , I use the Module function of SaveToFile  to upload The Module to PC .But The alarm happened, that is "General file handing error" , I test successful in the virtual IRC5 use RS,But not in the real IRC5
My program like this:

                wModule = GudData.mTasks[wTaskDeep].GetModule(TvProgram.SelectedNode.Text);
                    
                if (wModule.IsSystem == false)
                {
                    if (File.Exists(@C:ABB + wModule.Name + ".mod"))
                        File.Delete(@C:ABB + wModule.Name + ".mod");
                   
                  
                    wModule.SaveToFile(wPath); 
                    Stream s = new FileStream(@C:ABB + wModule.Name + ".mod", FileMode.Open); 

                    byte[] b = new byte[s.Length]; 

                    s.Read(b, 0, (int)s.Length);     

                    s.Close();
                    string wPrograms = Encoding.Default.GetString(b);

                    RTProgram.Text = wPrograms;
                }


 

Please help me or give me some sample code.


Thanks sincerely
Martin-jie.zhang2012-12-14 03:21:39

Comments




  • The generic error is due to the controller not being able to save outside of its file system, ie local disk.
     the module.SaveToFile assumes a local disk, like (HOME)$, or similar.
    [quote]NOTE!All program files must
    reside in the file system of the controller and not locally on the PC. In order
    to load a program from the PC, you must first download it to the controller by
    using theFileSystem.PutFile method.
    [/quote]It works the same way in the other direction using the GetFile method.
     
    So if you are going to do it like that then you need to first save the module locally on the controller, and then use GetFile to get it over to the PC.
     
    Here is a sample in VS2010 I created for you. It's using 5.14.03 resources so you might want to reset the references and rebuild it using whatever you got in the controller.

  • Thank you  very much ,
    i have finished ,

    thanks sincerely