FileSystemWatcher - Multiple Zip Files?

Sep 13, 2010

I am in the process of writing a windows service that will be replacing a vbscript that runs via a scheduled task currently. It currently runs on 350 kiosk machines in 350 different locations.Here is what the vbscript currently does:

1. The machine receives a ZIP file in the RECEIVE directory. Configuration_09122010_1234.zip. This file contains software configuration files that need to be copied to specified folders on the machine and to another machine on the local LAN where this kiosk is located.

2. The zip file is extracted to a folder with the same name as the zip file.Inside the zip file is an instruction file (.txt) and files that are referenced in the instruction file.

3. Opens the instruction file and performs the instructions in the file. Example: (this would copy pricingfile1.dbf to \mymachinecapplication1pricing, and then execute softwaresoftwarepatch1.exe which is located in \mymachinecpatches)

pricingfile1.dbf, \mymachinecapplication1pricing, copy
softwarepatch1.exe, \mymachinecpatches, run

4. Once all of the actions in the instructions file are completed, the folder where the zip file was extracted is deleted and the zip file is renamed to configuration_09122010_1234.zip.applied to show that it was processed by the script. Also, because the script is a scheduled task, this ensures that the file is not applied more than 1 time.

So I have started writing the service using the FileSystemWatcher. Basically I look in the receive folder for any file that looks like Configuration_MMddyyyy_*.zip and unzip it to a folder of the same name.

1. I have been doing some reading about the FileSystemWatcher Created event.I read an article about how the Created event fires as soon as the first byte is written but doesn't necessarily mean that the complete file has arrived at the machine. A post I read involved a .csv file and it mentioned that you try to open the file and catch any errors - if you cannot open the file, it hasn't arrived yet. This makes sense to me but I don't know what the equivalent would be to a zip file. It's not the same as opening a txt or csv file.

2. There are times that we send more than 1 configuration file in the same day, or even, at the same time. Above I mentioned the name was Configuration_<date>_1234.zip. The 1234 is a sequence number, always incremented. The idea is for 1234 to be applied before 1235 and 1236. So if I had 2 files sent *at the same time* and I want them to apply in order, how would I do this? I thought about when I am applying 1 file to stop looking for changes until after the apply process is completed, but then I *think* I would miss any file that arrived while I EnableRaisingEvents = false?

View 1 Replies


ADVERTISEMENT

Will FileSystemWatcher Process Multiple Files At Once?

Jun 1, 2009

I have a Windows service that is watching a folder for files that will be placed there.(Created in Visual Studio 2005.)The files each represent a transaction, and the transactions have to be kept in order.As I process each file (transaction), I want to forward it to someone else.(The someone else wants them kept in order.)It looks like I can't paste multiple files into a folder simultaneously and still be sure that they will be processed in the order of the original date and time they were created.Nor can I be sure that they would be read in name order.(FileSystemWatcher would grab them in any old order it chose.)So I think I will have to move the files into the folder one at a time, in the proper sequence.But I'm wondering if I could get into a "racing" situation.

When FileSystemWatcher detects a file in a folder, it creates a new thread for your event handler to operate on.If it detects a second file while still processing the first file, would it then create yet another thread?If that is the case, then if File1.xml takes longer to process than File2.xml, it seems like File2.xml might finish first, resulting in my transactions getting out of order.In my own experiments,I have not seen evidence that multiple files are really processed simultaneously.I write messages to a log file as I process each transaction, and I never see messages from File1.xml's processing intermingled with File2.xml's messages.This seems to be true even when I paste both files into the folder simultaneously.it only keeps one event-handling thread going at a time, and queues up the events as they come, processing them on that single thread.Otherwise, I'll have to do something to ensure they are kept in order.

View 9 Replies

.net - FileSystemWatcher Multiple Change Events?

Jan 16, 2009

I have the following code:

Imports System.IO
Public Class Blah
Public Sub New()
InitializeComponent()

[code]....

When I run it and save changes to a file on my C drive, the code works great, except it executes the watcher_Changed() method four times. The changeType is "4" every time.

View 14 Replies

FileSystemWatcher And Locked Image Files?

Apr 13, 2012

I have a filesystemwatcher waiting for .jpg files to arrive from the camera.he file system watcher invokes a delegate (it works but is that the proper way to handle it?) sub that does a couple of things:1. Adds the just arrived file name to a table2. Attempts to display the image in a picturebox on the form. When it displays the image it imprints some information on the image that the user has entered on the screen. I use a file stream to retrieve the image.The problem is, I'm getting a file in use orror on the "Img = ystem.Drawing.Image.FromStream(fs)"statement. Not all the time. Sometimes I can add three or four files to the folder in rapid succession with no issue. But then out of the blue the error will occur. Sometimes it's there to stay but other times it will go away and allow me to add morefiles.

View 2 Replies

FileSystemWatcher And Save Excel Files

Aug 21, 2011

I am trying to write an app that monitora a folder, and subfolders, amd makes a copy of any file that gets saved there, (or renamed, moved etc). Filesystemwatcher does a pretty good job of it, untili someone saves an Excel spreadsheet. Excel does about 9 different file system operations just to save the file. What happens is I get events for tempo files being saved, then renamed, or deleted in a very quick succession. All I want is the final spreadsheet, but these changes happen so quickly is causes my app to crash. Anybiody have any thoughts on how to hendle this?

View 3 Replies

Forms :: Filesystemwatcher Firing Files Twice?

May 29, 2011

ive just finished writing a file in VB 2010 and im using filesystemwatcher but ive found a problem whereas the filesystemwatcher fires the target twice everytime there is a change to the file.

ive looked around and found it to be a problem but cant seem to find a cure

View 1 Replies

Set The FileSystemWatcher.Filter To Check Only Two Files?

Jun 11, 2011

How do you set the FileSystemWatcher.Filter to check only two files.

Here's my code that doesn't even work.

watcher.Filter = "*.txt|*.ini"

View 5 Replies

Monitor Changes To The Registry Like Monitoring The Files And Folders Using Filesystemwatcher?

Apr 15, 2011

Can i monitor changes to the registry like monitoring the files and folders using filesystemwatcher?

View 10 Replies

Asp.net - Implement Security Trimming With A Website With Multiple Folders And Multiple Web.config Files?

Jun 18, 2012

I have a website that has highly granulised access and hence requires many web.config files. The problem is I would like to trim the menu so that only certain users will have access to certain folders. I have enabled trimming and setup roles in the sitemap, however when I access the page the menu is not show, as I am authorized to view the default page which is not in a subfolder. When I type the url of a page in sub folder's I have access.

How should I handle this:

A site map for each web.config file - don't know how this will work Removing the sub web.config file to only use a single one

View 3 Replies

Combining Image Files - Take Multiple Picture Files And Compact Them Into One File

Dec 10, 2009

I know this is out there and probably illogical but I was wondering if it was possible to take multiple picture files and compact them into one file.... and then retrieve them from the program later? Way to combine any amount of image files into one file

Module Module1
Sub combine()
Dim img1 As New Bitmap("i1.jpg")

[CODE]...

View 6 Replies

Searching Multiple Files In Multiple Sub-folders

Mar 30, 2010

I'm developing an application to help law enforcement retrieve and analyze logs and other files left by the use of Pidgin (a multi-protocol messenger client). Right now I'm nearly done, but I want to add the ability to search chat logs for user-defined words or phrases and I don't even know where to begin.

Chat logs are stored as html documents in a folder/sub-folder/sub-folder/sub-folder fashion, where each sub-folder can have dozens of sub-folders inside of it, and the final sub-folder can have dozens if not hundreds of chat logs. If anybody could point me in the right direction, I'd be very grateful.

(Also, this is the first program I've written since about 2005, and I'm essentially teaching myself VB as I go. If you'd like to see what I've cobbled together so far, you can find the program here.)

View 1 Replies

Merge Multiple Excel Files Into One Excel File And It Works For 3 Source Files But Its Not Working If Workbook With Worksheet Count Is > 3?

Aug 18, 2011

I'm trying to copy multiple excel source files into one excel file. My current code is working only for 3 source files..If more than 3 files are there, it doesn't copy the data but creates blank work sheet in the output excel file. Lets say I have a source folder with 5 excel files. Each workbook contains one worksheet with data. It copies upto 3 worksheets along with data into output excel file.

Lets say excel1 contains A as work sheet, excel2 contains B as work sheet ,excel3 contains C as work sheet ,excel4 contains D as work sheet ,excel5 contains E as work sheet .Now my output excel file should look like..OutputExcel with A, B, C, D, E along with respective data.But my current code is giving output as A,B,C worksheets along with respective data but its creating blank sheet1,sheet2 in place of D & E.

SSIS Script Task Vb.Net Code:

Public
Sub Main()
Dim filePath
As
String =

[code].....

View 1 Replies

FTP And FileSystemWatcher

Feb 20, 2012

I have my application watching my desktop, pictures, music, and document folders.[code]What would I need to put into logrename() in order for it to automatically upload the renamed file onto my server?

View 5 Replies

Any Way To Create Multiple Files?

Jul 2, 2012

I know how to create a file, but would it be possible to create multiple files? the number I would like to create is determined from the number in a textbox, i.e., if the textbox had 2 then I would create 2 files, if it had 5 then I would create 5 files.

My code to create file
System.IO.File.WriteAllText("C:\Test.txt", "")

View 2 Replies

Associate Multiple Files With App?

Jun 10, 2012

I am trying to associate multiple files with my app i have done associating files but when i try to open multiple files app open just one file, to open the file iam using this code in form load event

For Each arg In My.Application.CommandLineArgs
open_File(return_rtb, arg)
Next arg

And the second problem is myApp is single instance app how to catch if user double click on a file while myApp is running like form load event for first time.

View 1 Replies

Checking Multiple Files At Once?

Jun 14, 2012

Making a system to check for files existing in a network (for our tv address system, pawn shop stuff)Anyway, the command1 checks if d1.txt exists, then d2.txt and fills out the boxes, Instead of 10000 if statements?

Below is example of my current code

Private Sub Command1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Command1.Click
If My.Computer.FileSystem.FileExists(Text1.Text + "d1.txt") Then
d1.Checked = True

[code]....

Basically it's a bunch of check boxes, that check if the corrosponding file exists

View 5 Replies

Combine Multiple Files Into One?

Jan 11, 2010

How do I combine multiple files into the one file with a new extension. No need to be compressed. So I avoid Zip or similar solutions. (Actually don't want to add third party solutions into my application.)

View 13 Replies

Copy Multiple Files Into One?

Aug 13, 2009

In the cmd prompt, I can copy multiple files into one file, and I was wondering, how would I do that in VB 08?

View 10 Replies

Copying Multiple Files W/ UI

Jul 10, 2009

I know you can copy a file using:[code]The only way I know how to copy multiple files is by using a for loop, but if you choose to display a dialog box, you get a dialog box for every file you copy instead of one showing the progress of all the files.So with that said, is there any way to copy multiple files, and only have one dialog box displayed?

View 2 Replies

Delete Multiple Files Using *

Dec 15, 2004

I was trying to do something like this (that worked with the Kill method of VB6) System.IO.File.Delete(OrderInfo.ParentFolderPath & "NJ0*.DTA") because there are several files that start with NJ0 and end with .DTA

[Code]...

View 3 Replies

Downloading Multiple Files Specified In TXT Doc?

Aug 18, 2010

I've come up with a way of downloading multiple files specified in a txt doc held on a web server. The problem is it only downloads files not folders, im using the following from the codebank to download the files currently:

Try
mCurrentFile = GetFileName(URL)
Dim WC As New WebClient
WC.DownloadFile(URL, Location)
RaiseEvent FileDownloadComplete()
Return True
Catch ex As Exception
RaiseEvent FileDownloadFailed(ex)
[Code] .....

Can I modify this to allow downloading of folders too or will I have to use a completely different method?

View 2 Replies

Downloading Multiple Files?

Jan 10, 2011

I'm trying to code a program that can download multiple files at once (on different threads of course). I have created a custom listview component that will allow me to add a progressbar directly to it. What my real question is, how can i take a url given by the user from an input box and create a new webclient to handle the downloadasynchronously

View 2 Replies

FTP Upload Of Multiple Files?

Dec 7, 2011

I am trying to upload all files in a folder using the FTP method below... I just can not figure out how to pass the list of files in the folder to the FTP method which works great for single files

vb.net
UploadFile(filetoupload, uploadpath, My.Settings.User, My.Settings.Pass)
End Sub

[Code]....

with the aim of generating a list of files in the folder and then looping them though the ftp method, currently have a Error1Value of type '1-dimensional array of String' cannot be converted to 'String'. error based on above code

View 6 Replies

How To Add Multiple Files In Code

Nov 5, 2010

I have this code so I was wondering how do you put in multiple files: E.g:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If System.IO.File.Exists("C:fileiwannadelete") Then
My.Computer.FileSystem.DeleteFile("C:fileiwannadelete")
End If
End Sub

View 1 Replies

How To Compress Multiple Files Into One

Nov 21, 2010

I want to have a backup feature which takes about 7 txt files and compresses/packs them into one file. Then if required at a later stage I can unpack all 7 files from the packed file. I do not need any compression as such just to make one file from 7, then 7 from from that one, if you understand what I mean. I have read there are some native libraries in .NET Framework 2.0 called DeflateStream and GZipStream. Can these be used?

View 3 Replies

How To Download Multiple Files

Apr 9, 2011

I am new in Webserver. My application is on VS2008(VB.NET) in windows application. Some Customer upload orders in .txt files. Now I want to download all the .txt file at once. How can I do that?

View 17 Replies

Launching Multiple Files From Just One EXE Possible?

Nov 18, 2010

When I click a button to Shell something, instead of having to specify where the exe (or whatever file it might be) is, i was wondering if I could combine it with VB to make it something like this. Shell ("Internet Explorer.exe"). Also, have VB save the file so anywhere I take that single exe file i made with VB, the exe file I want to shell goes with me. So that way I can launch multiple files from just one exe file and not have any directories to worry about.

View 7 Replies

Multiple Directories And Their Files?

Feb 22, 2011

I have been asked to transfer multiple directories and their files from one drive to another but using a different directory name i.e Source Drive equals a: and the destination drive equals s:CATE ResultsA380, plus the orginal directory and files must be added to the destination path.

View 3 Replies

Process Multiple Files?

Apr 16, 2009

made a simple application which converts a PDF to csv.making some changes to have the app read multiple PDF's and convert into one CSV.

Heres my code.
Imports System.IO.StreamWriter
Imports System.IO

[code].....

View 2 Replies

Read Multiple XML Files?

Aug 17, 2010

I have a VERY basic knowledge of VB. I'm having trouble figuring out how to read multiple xml files when a user selects them from a listbox. Below is what I have so far. Currently this will only read one xml file. When I change "Dim strDir As String = PlayListBox.SelectedItem" to "Dim strDir As String = PlayListBox.SelectedItems" the code doesn't work.[code]...

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved