Just a quick question (I hope): When I use File.Move it gives me an error:
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:
My code:
File.Move(FileLocation, destinationPath);
And the contents of the variables:
destinationPath="c:/program files (x86)/steam\\steamapps\\common\\portal 2\\Test\\Test.docx"
FileLocation="C:\\Users\\Yoshie\\Local Settings\\Documents\\Test.docx"
Thanks! EDIT: I really feel like an idiot now. I didn't realise that the destination folder had to exist! I stupidly assumed that the destination folder would be automatically created if it didn't already exist. Sorry for wasting your time, but thanks for the answers anyway! (I now know that I can use @ to stop escaping, so thats good to know) Thanks anyway, and again, sorry!
Please use \ and not / as well as use @ like @"path".
Does this make any difference?
destinationPath=@"c:\program files (x86)\steam\steamapps\common\portal 2\Test\Test.docx";
FileLocation=@"C:\Users\Yoshie\Local Settings\Documents\Test.docx";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With