Camillia
asked on
What type of project i need for filesystemwatcher
I'm trying to write a code that uses filesystemwatcher. Looking for examples but not sure what type of project this goes into? not a web app...i doubt. Has to be something like winform??
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
>>you gave me that link
Sorry, I never look at the name of the question asker.
>>I need to check for file named "PX.txt" or PXDelta.txt"
Check my example. You need to set the .Filter property to "PX*.txt" and you also need to handle the created event.
Sorry, I never look at the name of the question asker.
>>I need to check for file named "PX.txt" or PXDelta.txt"
Check my example. You need to set the .Filter property to "PX*.txt" and you also need to handle the created event.
ASKER
i'll keep this question open for one or 2 more days. Thanks
ASKER
ok, this is what i need to do:
1. there are 6 files i need to monitor PX.txt, PXDelta.txt, NX.txt,NXDelta.txt, WAR.txt and WARDelta.txt ... this is done with .Filter property?
2. Parse the file name: see if it has "delta" in it or not and also get the name "px or nx or war" Not sure how to do this
3. If they're in the folder, I will call a stored proc (i know how to do this)
4. Rename the files with datatime at the end.
How can I do #1 and #2?
1. there are 6 files i need to monitor PX.txt, PXDelta.txt, NX.txt,NXDelta.txt, WAR.txt and WARDelta.txt ... this is done with .Filter property?
2. Parse the file name: see if it has "delta" in it or not and also get the name "px or nx or war" Not sure how to do this
3. If they're in the folder, I will call a stored proc (i know how to do this)
4. Rename the files with datatime at the end.
How can I do #1 and #2?
why don't you use .Filter = "*.txt" and in the Created event handler use a switch statement for your filename pattern (ignoring all other that are not corresponding)?
ASKER
So this takes care of #1.
Then for #2...use that Switch statement to get the file name (i think that's correct, no?)
Then for #2...use that Switch statement to get the file name (i think that's correct, no?)
#2 use the filename received in the Created event to switch against your PX, PXDelta, NX, ...
ASKER
not sure what that means but i will for examples
in your Create event handler
if e.FullPath.Contains("PX.tx t") then
'do something for PX file
elseif e.FullPath.Contains("PXDel ta.txt") then
'do something for PXDelta file
...
end if
if e.FullPath.Contains("PX.tx
'do something for PX file
elseif e.FullPath.Contains("PXDel
'do something for PXDelta file
...
end if
ASKER
ah, yes, thanks. I will try and post back
ASKER
Can I schedule a windows form application??
Sure you. But why would you schedule it if the watcher is constantly checking?
ASKER
hmm...so i just leave the app open on the server if i dont schedule it? Maybe "scheudle" is the wrong word. I need the app to keep checking. It has a form interface. Just leave that form open on the server??
yes just leave it running
ASKER
i will unless my manager tells me no :)
ASKER
eric, i have a related question here. Can you take a look?
https://www.experts-exchange.com/questions/27485384/Filewatcher-checking-for-file-completed-using-this-example.html
https://www.experts-exchange.com/questions/27485384/Filewatcher-checking-for-file-completed-using-this-example.html
ASKER
Reading this http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx
I need to use NotifyFilters.FileName ?