我用FileUpload.SaveAs方法保存文件时,出现了这样的错误,我要实现的功能是,上传文件到另一个服务器或者域名下,而不是上传到本程序的文件夹下,如(http://域名:端口号/文件夹/),不知道该如何实现

解决方案 »

  1.   

    谢谢showbo ,不过具体怎么实现呢,能给我一些代码吗,再次感谢
      

  2.   

    两种办法:
    一种是在本地启动一个服务,上传的文件先存放本地服务器,通过Windows服务转移到另外一台服务器上,转移成功之后再从本地删除;
    另一种办法通过TCPClientstatic void Connect(String server, String message) 
    {
      try 
      {
        // Create a TcpClient.
        // Note, for this client to work you need to have a TcpServer 
        // connected to the same address as specified by the server, port
        // combination.
        Int32 port = 13000;
        TcpClient client = new TcpClient(server, port);
        
        // Translate the passed message into ASCII and store it as a Byte array.
        Byte[] data = System.Text.Encoding.ASCII.GetBytes(message);             // Get a client stream for reading and writing.
       //  Stream stream = client.GetStream();
        
        NetworkStream stream = client.GetStream();    // Send the message to the connected TcpServer. 
        stream.Write(data, 0, data.Length);    Console.WriteLine("Sent: {0}", message);             // Receive the TcpServer.response.
        
        // Buffer to store the response bytes.
        data = new Byte[256];    // String to store the response ASCII representation.
        String responseData = String.Empty;    // Read the first batch of the TcpServer response bytes.
        Int32 bytes = stream.Read(data, 0, data.Length);
        responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);
        Console.WriteLine("Received: {0}", responseData);             // Close everything.
        stream.Close();         
        client.Close();         
      } 
      catch (ArgumentNullException e) 
      {
        Console.WriteLine("ArgumentNullException: {0}", e);
      } 
      catch (SocketException e) 
      {
        Console.WriteLine("SocketException: {0}", e);
      }
        
      Console.WriteLine("\n Press Enter to continue...");
      Console.Read();
    }
      

  3.   

    还可以在要保存的服务器上启动WebService,将文件名传递给webService,并且将文件转换成byte[]传递过去保存就是了。
      

  4.   

    和你当前服务器保存文件的代码一样啊,只是放到另外一个服务器上运行而已你使用FileUpLoad.SaveAs不能直接保存到另外的服务器上的吧...要不还用网络编程干什么呢.