프로젝트 파일 경로에서 텍스트 파일의 내용을 자바 스크립트의 문자열 변수로 복사하려면 어떻게해야합니까?
아래 코드를 사용했지만 "액세스 거부"오류가 발생합니다.
var sHTML = "";
var rawFile = new XMLHttpRequest();
rawFile.open("GET", "file://~/Templates/NewGridTemplate.txt", true);
sHTML = rawFile.responseText;
C # 코드로 HTML 템플릿을 읽은 다음이를 HTML 코드로 보내고 innerHTML에 할당합니다.
using (StreamReader sr = new StreamReader(@"D:\Template.html")){
// Read the stream to a string, and write the string to the console.
obj.svar = sr.ReadToEnd().Replace(Environment.NewLine, " ");
//Console.WriteLine(line);
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다