애플리케이션 MVC3 애플리케이션이 있습니다. 특정 양식을 제출할 때처럼 데이터베이스에 쓰지 않아도되도록 XML을 사용하여 세부 사항을 기록하고 싶습니다.MVC3 응용 프로그램 : 서버에 파일을 저장하는 데 사용할 폴더는 무엇입니까?
질문은 어떤 폴더를 사용해야합니까, 내가 본 예 중 일부는 App_Data 폴더를 제안합니다. 최소한의 이슈에 대한 표준 또는 권장 사항은 무엇입니까? 서버에 게시 할 때 로컬 잘 작동하지만
// Create a new XmlSerializer instance with the type of the test class
var serializerObj = new XmlSerializer(typeof(CourseApplicationVM));
// Create a new file stream to write the serialized object to a file
var filename = string.Format("{0}-{1}-{2}{3}", "CourseApp",
viewModel.Course.Code + viewModel.Applicant.Name, DateTime.Now.Ticks, ".xml");
var filepath = Path.Combine(Server.MapPath("~/App_Data/Log"), filename);
TextWriter writeFileStream = new StreamWriter(filepath);
serializerObj.Serialize(writeFileStream, viewModel);
// Cleanup
writeFileStream.Close();
:
그래서 나는 이것을 사용합니다. 폴더 구조를 살펴보면 게시 할 때 App_Data 폴더가 없으므로 놀라지 않습니다. 이 오류에 이르게 : 왜 해당 폴더를 (이 최대 게시해서는 안) 없어했다입니다Could not find a part of the path 'C:\inetpub\wwwroot\MyApplication\App_Data\Log\CourseApp-0385JoeBloggs-634734549879496695.xml'.
Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\inetpub\wwwroot\MyApplication\App_Data\Log\CourseApp-0385JoeBloggs-634734549879496695.xml'.
입니까? 그리고 그러한 것들을 구하기위한 일반적인 위치는 무엇입니까?
감사합니다, 데이비드
솔루션에 추가 한 적이 있습니까? – Rab
App_Data에 로그 폴더를 추가하고 예를 포함 시켰습니다. –
그래서 구조를 게시하기 전에 의도적으로 폴더에 불필요한 파일을 추가해야합니까? 가짜 파일을 추가하여 파일을 만들었습니다. 광기. –