I've는 다음 ConnectionString을 얻었다. mdf 파일은 Datenbank
폴더에 있습니다. 즉, 연결 문자열에 입력 한 폴더에 있습니다.를 ConnectionString의 MDF 파일은
..\\
처럼 보이지 않습니다. 아무도 그 문제에 대한 해결책을 가지고 있습니까?
I've는 다음 ConnectionString을 얻었다. mdf 파일은 Datenbank
폴더에 있습니다. 즉, 연결 문자열에 입력 한 폴더에 있습니다.를 ConnectionString의 MDF 파일은
..\\
처럼 보이지 않습니다. 아무도 그 문제에 대한 해결책을 가지고 있습니까?
다음 코드를 사용하여 dir을 계산할 수 있습니다.
//these two lines get the executable's directory
Uri u = new Uri(Assembly.GetExecutingAssembly().GetName().CodeBase);
DirectoryInfo d = new DirectoryInfo(Path.GetDirectoryName(u.LocalPath));
//this goes up two directories and combines that directory with the rest
//of the path to the file
string path = Path.Combine(d.Parent.Parent.FullName, @"Datenbank\FarmersCalc.mdf;");
Console.WriteLine(path);
경로에 GetDirectoryName에 대한 정의가 없습니다 ... – user896692
어떤 버전의 csharp를 사용하고 있습니까? 이 작업을하기 위해서는'System.IO'와'System.Reflection' 네임 스페이스를 포함시켜야합니다. 그게 문제라고 생각하지 않습니다. –
정확한 오류는 무엇입니까? –
나는 믿는다 | DataDirectory | 프로젝트 폴더 아래의 "App_Data"폴더를 나타냅니다. –
제목 앞에 "C#"등을 붙이지 마십시오. 그 태그가있는 것입니다. –