Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to Transfer xml file from remote server to another

How to Transfer xml file from remote server to another

Scheduled Pinned Locked Moved C#
sysadminhelpxmltutorial
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 12626416
    wrote on last edited by
    #1

    I have some problem for- transfer xml file from one server to another using ip address ,same network is working fine,but different network is not working,cant able to connect,anybody can help me to solve this

    L J 2 Replies Last reply
    0
    • U User 12626416

      I have some problem for- transfer xml file from one server to another using ip address ,same network is working fine,but different network is not working,cant able to connect,anybody can help me to solve this

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      How are you trying to do the transfer? Also, what connection problems are you getting, could it be firewall blocking access?

      1 Reply Last reply
      0
      • U User 12626416

        I have some problem for- transfer xml file from one server to another using ip address ,same network is working fine,but different network is not working,cant able to connect,anybody can help me to solve this

        J Offline
        J Offline
        John C Rayan
        wrote on last edited by
        #3

        Can you provide us with more details? What have you tried so far ? Post your code here. When you say different network , how do you connect to the network? Do you have permission to connect to the network? ( Credentials etc).

        U 2 Replies Last reply
        0
        • J John C Rayan

          Can you provide us with more details? What have you tried so far ? Post your code here. When you say different network , how do you connect to the network? Do you have permission to connect to the network? ( Credentials etc).

          U Offline
          U Offline
          User 12626416
          wrote on last edited by
          #4

          Yes thats the problem how to connect remote system using ip address using coding

          D 1 Reply Last reply
          0
          • U User 12626416

            Yes thats the problem how to connect remote system using ip address using coding

            D Offline
            D Offline
            dlhale
            wrote on last edited by
            #5

            Show us some code Tell us where the code breaks What works What dosen't We're not claivoiant

            1 Reply Last reply
            0
            • J John C Rayan

              Can you provide us with more details? What have you tried so far ? Post your code here. When you say different network , how do you connect to the network? Do you have permission to connect to the network? ( Credentials etc).

              U Offline
              U Offline
              User 12626416
              wrote on last edited by
              #6

              private void FileSave() { SqlConnection con = new SqlConnection(connstr); SqlCommand cmd = new SqlCommand("Sp_Rep", con); cmd.CommandType = CommandType.Text; con.Open(); string val = cmd.ExecuteScalar().ToString(); XmlDocument xmldoc = new XmlDocument(); xmldoc.LoadXml(val); xmldoc.Save("C://Shankar//Shankar.xml"); FromLocal(); ToRemote(); con.Close(); } public void FromLocal() { try { //string hostName = Dns.GetHostName(); // Retrive the Name of HOST // Get the IP //string myIP = Dns.GetHostByName(hostName).AddressList[0].ToString(); Console.WriteLine("That program can transfer small file. I've test up to 850kb file"); Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); // m_socWorker = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); //String szIPSelected = "172.31.1.111"; //String szPort = "80"; String szIPSelected = "10.2.2.28"; String szPort = "580"; int alPort = System.Convert.ToInt16(szPort, 10); System.Net.IPAddress remoteIPAddress = System.Net.IPAddress.Parse(szIPSelected); System.Net.IPEndPoint ipEnd = new System.Net.IPEndPoint(remoteIPAddress, alPort); sock.Connect(ipEnd); //IPEndPoint ipEnd = new IPEndPoint(IPAddress.Any); // Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); ///Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); // sock.Bind(ipEnd); sock.Listen(100000); //clientSock is the socket object of client, so we can use it now to transfer data to client if(ipEnd != null) { Socket clientSock = sock.Accept(); string fileName = "Shankar.xml"; string filePath = "C://Shankar//Shankar.xml";//Your File Path; byte[] fileNameByte = Encoding.ASCII.GetBytes(fileName); byte[] fileData = System.IO.File.ReadAllBytes(filePath + fileName); byte[] clientData = new byte[4 + fileNameByte.Leng

              L 1 Reply Last reply
              0
              • U User 12626416

                private void FileSave() { SqlConnection con = new SqlConnection(connstr); SqlCommand cmd = new SqlCommand("Sp_Rep", con); cmd.CommandType = CommandType.Text; con.Open(); string val = cmd.ExecuteScalar().ToString(); XmlDocument xmldoc = new XmlDocument(); xmldoc.LoadXml(val); xmldoc.Save("C://Shankar//Shankar.xml"); FromLocal(); ToRemote(); con.Close(); } public void FromLocal() { try { //string hostName = Dns.GetHostName(); // Retrive the Name of HOST // Get the IP //string myIP = Dns.GetHostByName(hostName).AddressList[0].ToString(); Console.WriteLine("That program can transfer small file. I've test up to 850kb file"); Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); // m_socWorker = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); //String szIPSelected = "172.31.1.111"; //String szPort = "80"; String szIPSelected = "10.2.2.28"; String szPort = "580"; int alPort = System.Convert.ToInt16(szPort, 10); System.Net.IPAddress remoteIPAddress = System.Net.IPAddress.Parse(szIPSelected); System.Net.IPEndPoint ipEnd = new System.Net.IPEndPoint(remoteIPAddress, alPort); sock.Connect(ipEnd); //IPEndPoint ipEnd = new IPEndPoint(IPAddress.Any); // Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); ///Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); // sock.Bind(ipEnd); sock.Listen(100000); //clientSock is the socket object of client, so we can use it now to transfer data to client if(ipEnd != null) { Socket clientSock = sock.Accept(); string fileName = "Shankar.xml"; string filePath = "C://Shankar//Shankar.xml";//Your File Path; byte[] fileNameByte = Encoding.ASCII.GetBytes(fileName); byte[] fileData = System.IO.File.ReadAllBytes(filePath + fileName); byte[] clientData = new byte[4 + fileNameByte.Leng

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                Socket clientSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);

                Stream sockets use the TCP protocol; see SocketType Enumeration (System.Net.Sockets)[^]

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups