<?xml version="1.0" encoding="utf-16"?><customize><COR_CUSTOM_FIELD U_RuleName="GEN_10152: Filewatcher" U_Type="0" U_Action="0" U_Warning=" " U_WarningText="" U_WarningBox=" " U_WarningStatus=" " U_Active="Y" U_FormTypeBasis="" U_ItemUIDBasis="" U_ColumnBasis="" U_FormType="" U_ItemUID="" U_Column="" U_EventType="-3" U_Before=" " U_Mode="-1" U_Refresh=" " U_EasyFunctionRule="" U_Creator="" U_LastModified="18.07.2012 15:37:52" U_LastModifiedBy="1" U_Permission="" U_ErrorBox=" " U_ErrorStatus=" "><U_Expression>/****** General Information *****	Creator: coresystems ag, ehm@coresystems.ch	Create Date: 2012-03-20 ***** StartConfDesc *****	This function has been delivered by coresystems ag as a sample. This sample has been tested with a SAP Business One demo database and is delivered without further warranties.***** Description: *****		This rule calls and creates a FileWatcher instance which waits for new created files in the given path***** Updates ******//****** General Information *****Creator: coresystems ag, ehm@coresystems.chCreate Date: 2012-03-20 ***** StartConfDesc *****This rule calls and creates a FileWatcher instance which waits for new created files in the given path. The methods used for the fileWatcher instance must be defined in the extended code.***** EndConfDesc ***** ***** Updates *****2012-03-20, ehm: Initial Rule*/string ruleName = pVal.RuleInfo.RuleName.ToString();string errorMessage = "Error in Optimizer Rule '" + ruleName + "'"; try{	CreateWatcher(@"C:\FileWatcher");} catch(System.Exception ex){	StatusBar.WriteError(errorMessage + ": " + ex.Message);	Debug.WriteMessage(errorMessage + ": " + ex.Message, Debug.DebugLevel.Exception);}return true;</U_Expression></COR_CUSTOM_FIELD><COR_CUSTOM_GSCRIPT U_CodeType="0" U_Debug="N"><U_Script>/* GEN_10152: Filewatcher Extended Code START *//****** General Information *****Creator: coresystems ag, ehm@coresystems.chCreate Date: 2012-03-20 ***** StartConfDesc *****This methods are used for a fileWatcher instance***** EndConfDesc ***** ***** Updates *****2012-03-20, ehm: Initial Rule*//* Registers a FileWatcher for the given path */public void CreateWatcher(string path){	//Create a new FileSystemWatcher.	FileSystemWatcher watcher = new FileSystemWatcher();	//Set the filter to only catch TXT files if required.	//watcher.Filter = "*.txt";	//Subscribe to the Created event.	watcher.Created += new FileSystemEventHandler(watcher_FileCreated);	//Subscribe to other events, e.g. Rename if required	//watcher.Renamed += new RenamedEventHandler(watcher_Renamed);		//Set the path	watcher.Path = @"" + path;	//Enable the FileSystemWatcher events.	watcher.EnableRaisingEvents = true;}/* this method gets called, when a new file was created */void watcher_FileCreated(object sender, FileSystemEventArgs e){	//A new file has been created in the given path	string filename = get_watcher_FileCreated(this, e);		/* TODO: ENTER THE CODE TO EXECTUTE WHEN FILE WAS CREATED HERE */	StatusBar.WriteSucess("New File found: " + filename);}/* this method returns the filename of the newly created file */string get_watcher_FileCreated(object sender, FileSystemEventArgs e){	//returns filename from new file	return e.Name;}/* GEN_10152: Filewatcher Extended Code END */</U_Script><U_Usings>/* GEN_10152: Filewatcher Extended Code */using System.IO;</U_Usings></COR_CUSTOM_GSCRIPT></customize>