TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
my devel
NA
89
0
Folder Watch service does not work
May 18 2012 4:59 PM
Hi,
I've written a service to monitor a folder which is supposed to read a copied file (csv file) extract some information, close it and then move it to the another folder daily bases. file copy from another machine on the same domain. (service and Hot folder and moving destination are on same machine). so the problem is here:
1- whenever file be copy first time it's OK, it read and move it but second time which is next morning day while the service status is Start but it can't read file and show's error that
" System.IO.IOException:The process cannot access the file 'C:\HotFolder\123.csv'
System.IO.IOException: The process cannot access the file '
C:\HotFolder\123.csv
' because it is being used by another process. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize) at System.IO.StreamReader..ctor(String path) at
HotFoder
.HotFolder.fileSystemWatcher1_Created(Object sender, FileSystemEventArgs e) in C:\HotFolderFolder\Service1.cs: line 44 "
which line 44 is "StreamReader sr = new StreamReader('C:\HotFolder\123.csv');"
at the same time if I drag and drop same file to Hot Folder it works like a charm.
so if anyone knows what is wrong with that please help me.
Thanks a lot
Reply
Answers (
3
)
How to Create and Use a Windows 7 Password Reset USB
How to Install .net Windows Service