2
웹 응용 프로그램에서 FileUploader 컨트롤을 사용하고 있습니다. 지정된 폴더에 파일을 업로드하고 싶습니다. 특정 폴더가 아직 존재하지 않기 때문에 코드에 경로를 만들어야합니다."경로의 일부를 찾을 수 없습니다"오류가 발생합니다.
Could not find part of the path.
mscorlib.dll but was not handled in user code
Additional information: Could not find a part of the path
'C:\Users\seldarine\Desktop\PROJ\ED_Project\SFiles\Submissions\blueteam\Source.zip
내 filePath에 문제가 있다고 생각합니다. 이 내 코드의 일부입니다 :
//teamName is a string passed from a session object upon login
string filePath = "SFiles/Submissions/" + teamName+ "/";
//If directory does not exist
if (!Directory.Exists(filePath))
{ // if it doesn't exist, create
System.IO.Directory.CreateDirectory(filePath);
}
f_sourceCode.SaveAs(Server.MapPath(filePath + src));
f_poster.SaveAs(Server.MapPath(filePath + bb));
나는 Path.Combine를 사용에 동의합니다. 잘 작동한다. 감사. – Enovyne
디렉토리가 있는지 확인할 필요가 없습니다. '디렉토리가 이미 존재하면이 메소드는 새로운 디렉토리를 작성하지는 않지만 기존 디렉토리의 DirectoryInfo 오브젝트를 리턴합니다. 'https://msdn.microsoft.com/en-us/library/54a0at6s(v=vs.110).aspx – Necronomicron
@Necronomicron : 코드를 복사 할 때 잘 알지 못했습니다. –