I am doing a loop that will run all the time and when a change is done to the File(Source), then this file will be Copied/OverWrite file(Dest).
One problem that I have is that the if-statement that says:
if( CurrentSourceTime != LastSourceTime ) {} is running each loop ?

I dont really understand why this is happening. This if-statement should only execute if I have opened the file and write something new in the file(Source) and then save this changes and close it.
I can´t figure it out what this depends on.

private: System::DateTime LastSourceTime;
private: System::DateTime LastDestTime;

String^ Source = textBox2->Text; 
String^ Dest = textBox3->Text;

while (i > 0)  
{
Application::DoEvents();
i = (i + 1);
System::DateTime CurrentSourceTime = System::IO::File::GetLastWriteTime(Source);

if(  CurrentSourceTime != LastSourceTime )
{
	MessageBox::Show("This Message Will Show Each Loop ?");
	System::IO::File::Copy(Source, Dest, true);
	System::DateTime LastSourceTime = CurrentSourceTime;
}

	if( i > 10000 )
	{
		i = 4; // Is used to make the loop Go Forever
	}

} //End Of While Loop

That happens because you have [B]System::DateTime[/B] LastSourceTime = CurrentSourceTime; <=> LastSourceTime is there a variable local to the if -block. You have to change it to simply: LastSourceTime = CurrentSourceTime;

Okay, then I understand.. I didn´t think about that this was happening.

That happens because you have [B]System::DateTime[/B] LastSourceTime = CurrentSourceTime; <=> LastSourceTime is there a variable local to the if -block. You have to change it to simply: LastSourceTime = CurrentSourceTime;

This question has already been answered. Start a new discussion instead.