| | |
| | | [HttpGet("DownloadFtpFile")] |
| | | public IActionResult DownloadFtpFile([FromQuery] string itemNo, [FromQuery] string fileName) |
| | | { |
| | | // FTP服务器信息(请替换为实际信息) |
| | | // FTP服务器信息 |
| | | string ftpServer = "ftp://36.26.21.214"; |
| | | string ftpUser = "hm_ftp"; |
| | | string ftpPwd = "dell_123"; // 已更新为真实密码 |
| | | string ftpPwd = "dell_123"; |
| | | string ftpPath = $"{ftpServer}/IQC/{itemNo}/{fileName}"; |
| | | try |
| | | { |
| | |
| | | request.Method = System.Net.WebRequestMethods.Ftp.DownloadFile; |
| | | request.Credentials = new System.Net.NetworkCredential(ftpUser, ftpPwd); |
| | | request.UseBinary = true; |
| | | request.UsePassive = true; |
| | | request.UsePassive = false; |
| | | using (var response = (System.Net.FtpWebResponse)request.GetResponse()) |
| | | using (var ftpStream = response.GetResponseStream()) |
| | | using (var ms = new System.IO.MemoryStream()) |