- Home /
Should i use yield everytime?
Hi, iam having a little bit of a problem. Here is my code right away;
System.IO.File.Move (patch1, patch2); System.IO.File.Delete(patch1);
So the first line copies the file instead of just moving it into patch2. Because of that i am trying to delete it.Second line is supposed to be deleting the file which is patch1 but it is not. If i add a yield between the lines then it works i dont know why? Its taking long that is longer than a frame so it passes the second line sth? Why is this happening? Any idea?
Without any context in code, there is no way to help you understand what the issue is. There could be a million reasons why this is happening.
Answer by Statement · Apr 27, 2014 at 01:27 PM
File.Move should move the file, not merely copy it. You should not require a File.Delete call after File.Move.
See the example test in provided link. Maybe you can convert it to using Debug.Log instead of Console.WriteLine and see if you can see all of the console output.
Also check if you get any errors in the console to begin with, like exceptions.
See the list of exceptions in that documentation and see if you get any of those.
var screenShotPatch : String;
function Start ()
{
Application.CaptureScreenshot("capture.png");
screenShotPatch = System.IO.DirectoryInfo(Application.dataPath).Parent.FullName;
guiText.text = "" + screenShotPatch;
System.IO.File.$$anonymous$$ove(screenShotPatch + "/capture.png", Application.dataPath + "/capture.png");
}
Here is my script, it doesn't throw any exceptions or any errors,it does copy the file to where i want,it doesn't just move the file.I don't know why.
it looks like you posted another comment but i cannot see it :/