我试图指定我应该使用 StreamWriter 存储创建的文件的位置:
string getCurrentPath = Environment.CurrentDirectory;
StreamWriter writeFile = new StreamWriter(@"" +getCurrentPath + "\\NDependProject\\OceanAPIDependencies.xml");
writeFile.Close();
我收到此错误消息:
Unhandled Exception: System.IO.DirectoryNotFoundException: Could not find a part of the path 'D:\Project_Summer\ExtensionDirectoryTraversal\ExtensionDirectoryTr aversal\bin\Debug\NDependProject\OceanAPIDependencies.xml'. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, I nt32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions o ptions, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolea n useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean che ckHost) at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encodin g, Int32 bufferSize, Boolean checkHost) at System.IO.StreamWriter..ctor(String path) at ExtensionDirectoryTraversal.Program.Main(String[] args) in d:\Project_Summ er\ExtensionDirectoryTraversal\ExtensionDirectoryTraversal\Program.cs:line
15 按任意键继续。. .