<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" media="screen" href="/App_Themes/default/rss.xslt"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:evnet="http://www.mscommunities.com/rssmodule/"><channel><title>Comment Feed for Windows Service using FileSystemWatcher (TechOff on Channel 9)</title><atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/forums/techoff/261408-windows-service-using-filesystemwatcher/rss/default.aspx" /><image><url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.png</url><title>Comment Feed for Windows Service using FileSystemWatcher (TechOff on Channel 9)</title><link>http://channel9.msdn.com/forums/TechOff/261408-Windows-Service-using-FileSystemWatcher/</link></image><description>Windows Service using FileSystemWatcher</description><link>http://channel9.msdn.com/forums/TechOff/261408-Windows-Service-using-FileSystemWatcher/</link><language>en-us</language><pubDate>Mon, 03 Mar 2008 14:29:29 GMT</pubDate><lastBuildDate>Mon, 03 Mar 2008 14:29:29 GMT</lastBuildDate><generator>EvNet (EvNet, Version=1.0.3608.3122, Culture=neutral, PublicKeyToken=null)</generator><item><title>Re: Windows Service using FileSystemWatcher</title><description>Thanks Tommy ... your wrapper worked like a charm. No locks or nothing ... strange though that your wrapper did not show up in my endless google-searches ... would have saved me a lot of time.&lt;br&gt;&lt;br&gt;Thanks again ... C9 delivers everytime :D&lt;br&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/261408-Windows-Service-using-FileSystemWatcher/?CommentID=392712</link><pubDate>Mon, 03 Mar 2008 14:29:29 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/261408-Windows-Service-using-FileSystemWatcher/?CommentID=392712</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/392712/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Thanks Tommy ... your wrapper worked like a charm. No locks or nothing ... strange though that your wrapper did not show up in my endless google-searches ... would have saved me a lot of time.Thanks again ... C9 delivers everytime :D</evnet:previewtext><dc:creator>&amp;#193;rni Gunnar Ragnarsson</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/392712/Trackback.aspx</trackback:ping></item><item><title>Re: Windows Service using FileSystemWatcher</title><description>I don't know why you get the error, but I have some remarks. First of all, the lock is useless because you're just creating a new object each time.&lt;BR&gt;Secondly, concatenating the lines like that is far from optimal: it creates a lot of string objects that are unnecessary. There are actually functions in the .NET Framework to read an entire file. You can replace your entire StreamReader-block with this line:&lt;BR&gt;string fileContent = File.ReadAllText(e.FullPath, Encoding.Default);&lt;BR&gt;&lt;BR&gt;I don't know why you get the &lt;EM&gt;"file is locked"&lt;/EM&gt; error, but I don't think it's your code that locks the file. It's the application that drops the file in the folder. If you want to reliably be able to read the file, you'll have to try to read it multiple times. A while ago, I've written a class that does this automatically: a wrapper around FileSystemWatcher. You can find it here: &lt;a href="http://tommycarlier.blogspot.com/2007/01/filecreationwatcher.html"&gt;http://tommycarlier.blogspot.com/2007/01/filecreationwatcher.html&lt;/a&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/261408-Windows-Service-using-FileSystemWatcher/?CommentID=392692</link><pubDate>Mon, 03 Mar 2008 12:21:23 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/261408-Windows-Service-using-FileSystemWatcher/?CommentID=392692</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/392692/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>I don't know why you get the error, but I have some remarks. First of all, the lock is useless because you're just creating a new object each time.Secondly, concatenating the lines like that is far from optimal: it creates a lot of string objects that are unnecessary. There are actually functions in&amp;#8230;</evnet:previewtext><dc:creator>Tommy Carlier</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/392692/Trackback.aspx</trackback:ping></item></channel></rss>