0
C# 웹 응용 프로그램은 C
드라이브에 있습니다. 그러나 응용 프로그램은 사용자로부터 업로드 된 문서를 받고 D
드라이브에 저장합니다.C 드라이브의 다른 드라이브에서 문서 가져 오기
C
드라이브의 웹 응용 프로그램에서 HyperLink 컨트롤의 NavigateUrl 속성에있는 D
드라이브의 문서 경로를 지정하는 방법은 무엇입니까?
C# 웹 응용 프로그램은 C
드라이브에 있습니다. 그러나 응용 프로그램은 사용자로부터 업로드 된 문서를 받고 D
드라이브에 저장합니다.C 드라이브의 다른 드라이브에서 문서 가져 오기
C
드라이브의 웹 응용 프로그램에서 HyperLink 컨트롤의 NavigateUrl 속성에있는 D
드라이브의 문서 경로를 지정하는 방법은 무엇입니까?
는 서버 측에서, 당신은 byte[]
public void Page_Load(object sender, System.EventArgs e)
{
// create a FileStream from a path from local (D:, C:, E:, etc...)
FileStream file = File.OpenRead(@"d:\folder\yourfile.txt");
//Convert the stream to an array of bytes.
byte[] byteArray = file.ToArray();
// Clear all content output from the buffer stream
Response.Clear();
// Add a HTTP header to the output stream that specifies the default filename
// for the browser's download dialog
Response.AddHeader("Content-Disposition", "attachment; filename=foo.txt");
// Add a HTTP header to the output stream that contains the
// content length(File Size). This lets the browser know how much data is being transfered
Response.AddHeader("Content-Length", byteArray.Length.ToString());
// Set the HTTP MIME type of the output stream
Response.ContentType = "application/octet-stream";
// Write the data out to the client.
Response.BinaryWrite(byteArray);
}
많은 감사 펠리페 같은
Stream
및 응답 내에서이 객체를 파일을로드 할 수있다. 필요한 것은 하이퍼 링크의 NavigateUrl 속성을 지정하여 D : 드라이브의 문서로 이동하는 방법입니다. – AbdulQadir서버 측에서 실행하고 NavigateUrl을 URL로 리다이렉트하므로이 프로세스에서는 wwww 폴더 외부의 다른 드라이브 또는 폴더에서 파일을 가져 와서 클라이언트 측에 응답하기 때문에이 작업을 수행 할 수 없습니다. 당신은 URL에 매개 변수를 전달하고 그것을 queystring으로 처리 할 수 있습니다. –