This project has moved and is read-only. For the latest updates, please go here.

GetTask for testing existence of task

Sep 25, 2009 at 5:14 PM

I'm running this code on XP (so, V1), and when I try using GetTask to check for a task before I try deleting it, I get a FileNotFoundException from the low-level interop instead of null coming back. Not sure what the intended behaviour is, but peeking at the source I'm not clear if the internal exception bubbling up is the intended behaviour. I suspect returning null makes things more consistent between v2 and v1...but I know nothing about this area so I'll go with whatever you prefer :)

Sep 26, 2009 at 12:04 PM

It's a bug. (see: )

You can solve with this code that I used in my project:


TaskService taskService = new TaskService();
TaskFolder tasksFolder = taskService.GetFolder(@"\");
TaskCollection listOfTasks = tasksFolder.Tasks;

     Task theTask = listOfTasks[nameOfTask];
     //now you can use "theTask"
catch (System.IO.FileNotFoundException ex) 



Sep 26, 2009 at 12:07 PM

Where "nameOfTask" is the name of the task that you want find.


In Windows Vista/7 the GetTask method runs very well instead.


Sep 30, 2009 at 4:19 AM

This issue has been fixed as of code drop 30714 and will be in the released build 1.4.1.