다음과 같이 두 개의 다른 서버가 있습니다.재 파일을 사용하여 SFTP를 통해 다른 서버의 .pdf, .doc 파일을 열 수 없습니다.
1. 웹 서버 - 내 모든 업로드 된 파일이 perticular 위치에서 찾을 수 있습니다입니다/폴더 내가 가진 내 웹 응용 프로그램에서 지금
- 내 응용 프로그램입니다
2. 파일 서버을 찾을 수 있습니다 FileServer (업로드 한 파일)의 모든 업로드 된 파일을 표시하는 한 페이지를 만들었습니다.
하지만 문제는 그 파일을 열거 나 읽으려고 할 때 사용할 수 없다는 것입니다. 나는 SFTP의 모든 권리를 가진다. 그리고 Try-catch 블록에서 문제가 발생합니다. "코드가 최적화되었거나 네이티브 프레임이 호출 스택 위에 있기 때문에 표현식을 평가할 수 없습니다." REBEX를 사용하여 파일을 업로드하고 다운로드했습니다.
참고 : 내가 할 수
내 파일이 코드는 다음과 같다 읽기 (.PDF, .DOCX, .JPG 등)과 같은 간단한 텍스트 파일 (.txt)로가 아닌 다른 형식의 파일을 열 수 있습니다.
protected void LinkButton1_Click(object sender, EventArgs e)
{
try
{
LinkButton lbtn = (LinkButton)sender;
using (Sftp _sftp = new Sftp())
{
_sftp.Connect(serverNm, 22);
_sftp.Login(username, password);
_sftp.ChangeDirectory(currentDirectory);
Stream stream = _sftp.GetStream(lbtn.ToolTip.ToString(), FileMode.Open, FileAccess.Read);
StreamReader sourceStream = new StreamReader(stream);
Byte[] buffer = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
Response.Buffer = true;
if (lbtn.ToolTip.IndexOf(".pdf") > 0)
{
Response.ContentType = "application/pdf";
}
else if (lbtn.ToolTip.IndexOf(".txt") > 0)
{
Response.ContentType = "text/plain";
}
else if (lbtn.ToolTip.IndexOf(".xls") > 0)
{
Response.ContentType = "application/ms-excel";
}
else if (lbtn.ToolTip.IndexOf(".doc") > 0)
{
Response.ContentType = "application/msword";
}
else if (lbtn.ToolTip.IndexOf(".jpeg") > 0)// || lbtn.ToolTip.IndexOf(".jpg") > 0)
{
Response.ContentType = "image/jpeg";
}
else if (lbtn.ToolTip.IndexOf(".jpg") > 0)
{
Response.ContentType = "image/jpg";
}
else if (lbtn.ToolTip.IndexOf(".bmp") > 0)
{
Response.ContentType = "image/png";
}
Response.AddHeader("Content-Length", "attachment;filename=" + buffer.Length.ToString());
Response.BinaryWrite(buffer);
Response.End();
}
}
catch (Exception ex)
{
}
}
아무도이 문제를 해결할 수 있습니다.
최신 Mozila 브라우저를 사용하고 있습니다.
감사합니다.