thedarkness

// dirwatcher.cpp : main project file.

#include "stdafx.h"

System::Void serialize( System::Xml::Serialization::XmlSerializer^ xs, System:ApplauseateTime^ timeLastWritten )
{

System::Xml::XmlTextWriter^ writer = ( gcnew System::Xml::XmlTextWriter( "tlw.xml", System::Text::Encoding::UTF8 ) );

writer->Formatting = System::Xml::Formatting::Indented;

try
{
xs->Serialize( writer, timeLastWritten );
}
catch( System::Exception^ e )
{
System::Console::WriteLine( e->InnerException->Message );
}

writer->Close();

}

int main(array<System::String ^> ^args)
{
System::String^ sTargetDir =
"C:\some\directory\I\want\to\watch";

System::IO:ApplauseirectoryInfo^ dir = ( gcnew System::IO:ApplauseirectoryInfo( sTargetDir) );

System:ApplauseateTime^ timeLastWritten = dir->LastWriteTime;

System::Xml::Serialization::XmlSerializer^ xs = ( gcnew System::Xml::Serialization::XmlSerializer( timeLastWritten->GetType() ) );

if( System::IO::File::Exists( "tlw.xml" ) )
{
System::Xml::XmlTextReader^ reader = ( gcnew System::Xml::XmlTextReader( "tlw.xml" ) );
System:ApplauseateTime^ savedTimeLastWritten = dynamic_cast<System:ApplauseateTime^>( xs->Applauseeserialize( reader ) );
reader->Close();
if( savedTimeLastWritten->Equals( timeLastWritten ) )
return 0;
else
{
System::Windows::Forms:ApplauseialogResult confirmed = System::Windows::Forms::MessageBox::Show( "The Target Directory has Changed!",
"ApplauseirWatcher", System::Windows::Forms::MessageBoxButtons::OKCancel, System::Windows::Forms::MessageBoxIcon::Stop );

if( confirmed == System::Windows::Forms:ApplauseialogResult::OK )
{
serialize( xs, timeLastWritten );
}

}
return 0;
}

serialize( xs, timeLastWritten );

    return 0;
}

perkiset

TD -

I used a function years ago that popped an event when a DIR changed in any way (W2K)... is this the

.NET

  replacement for such, or is this an augmentation? I'm a little lost in the code to know what it's doing at all...

nutballs

hijack===
this is why i cant get going in

.net

 
System::Windows::Forms::MessageBoxButtons::OKCancel
System::Xml::Serialization::XmlSerializer
and those arent even that bad...
god i really gotta just jump into it.
maybe i can really screw myself up and

PHP

 

.net

 
hijack===

thedarkness

quote author=perkiset link=topic=127.msg668#msg668 date=1177632630

TD -

I used a function years ago that popped an event when a DIR changed in any way (W2K)... is this the

.NET

  replacement for such, or is this an augmentation? I'm a little lost in the code to know what it's doing at all...


It just checks the last write time of the directory and serializes it to disk, then on subsequent runs it reads (and unserializes) the last write time on the directory to see if it's changed, if it has it shows an alert.

Cheers,
td

thedarkness

quote author=nutballs link=topic=127.msg676#msg676 date=1177638118

hijack===
this is why i cant get going in

.net

 
System::Windows::Forms::MessageBoxButtons::OKCancel
System::Xml::Serialization::XmlSerializer
and those arent even that bad...
god i really gotta just jump into it.
maybe i can really screw myself up and

PHP

 

.net

 
hijack===


These can be reduced by using, for example;

using namespace System::Windows::Forms;

You can then refer to MessageBoxButtons::OKCancel

using namespace System::Xml::Serialization;

would allow you to change System::Xml::Serialization::XmlSerializer to just XmlSerializer

Not as bad as brainfish  Applause

Cheers,
td


Perkiset's Place Home   Politics @ Perkiset's