服务器上有一个word文档 c:\temp.doc , 如何把这个服务器上的word文档下载到本机呢?在线等。。

解决方案 »

  1.   

      /// <summary>
            /// 保存远程文件
            /// </summary>
            /// <param name="filePath">远程文件路径</param>
            /// <returns></returns>
            public string SaveFile(string filePath)
            {
                string fPath, fName, sPath;
                fPath = filePath.Replace("\\", "/");
                int start = fPath.LastIndexOf("/") + 1;
                fName = fPath.Substring(start, fPath.Length - start);
                if (newName)
                {
                    sPath = savePath + getFileName() + "." + getExtension(fName);
                }
                else
                {
                    sPath = savePath + fName;
                }
                
                System.Net.WebClient myWebClient = new System.Net.WebClient();
                try
                {
                    myWebClient.DownloadFile(fPath, sPath);
                }
                catch (Exception ee)
                {
                    throw ee;
                }
                finally
                {
                    myWebClient.Dispose();
                }
                return fName;
            }
      

  2.   

    基本思路:服务器端读取word,转换为byte[],客户端接收byte[],然后在保存为word。主要技术:文件流操作。