只是一个简单的问题(我希望):当我使用File.Move它给我一个错误:
System.IO.DirectoryNotFoundException was unhandled by user code
Message=Could not find a part of the path.
Source=mscorlib
StackTrace:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.__Error.WinIOError()
at System.IO.File.Move(String sourceFileName, String destFileName)
at Portal_2_Level_Installer.Form1.WorkMagic(String FileLocation) in C:\Users\Yoshie\Local Settings\Documents\Visual Studio 2010\Projects\Portal 2 Level Installer\Portal 2 Level Installer\Form1.cs:line 265
InnerException:
Run Code Online (Sandbox Code Playgroud)
我的代码:
File.Move(FileLocation, destinationPath);
Run Code Online (Sandbox Code Playgroud)
以及变量的内容:
destinationPath="c:/program files (x86)/steam\\steamapps\\common\\portal 2\\Test\\Test.docx"
FileLocation="C:\\Users\\Yoshie\\Local Settings\\Documents\\Test.docx"
Run Code Online (Sandbox Code Playgroud)
谢谢!编辑:我现在真的觉得自己像个白痴.我没有意识到目标文件夹必须存在!我愚蠢地假设目标文件夹将自动创建,如果它尚不存在.很抱歉浪费你的时间,但谢谢你的答案!(我现在知道我可以用@来停止逃跑,所以这很好知道)无论如何,谢谢,再次,对不起!
| 归档时间: |
|
| 查看次数: |
4091 次 |
| 最近记录: |