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
U
User 12626416
@User 12626416
Posts
-
How to Transfer xml file from remote server to another -
How to Transfer xml file from remote server to anotherYes thats the problem how to connect remote system using ip address using coding
-
How to Transfer xml file from remote server to anotherI 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