DataSet.WriteXML

S

Scott McNair

I have an app that a tiny xml file for each transaction. These files are
put in a pick-up folder for another app which takes the xml files out of
the pick-up folder and processes them.

My question is a simple (and perhaps stupid) one: when DataSet.WriteXML
executes, does it (A) write the XML file in a temp folder and then transfer
it to my target, or (B) write the XML file directly to the target?

My reason for asking is because I don't want to run into a situation where
my polling app is trying to pick up a file that my main app is in the
middle of writing.
 
S

sloan

This is probably a hack...but I'll mention it.

You could write the file as
"file_0001111.txt"
and then after it finishes writing out..
rename it to
"file_0001111.xml"

and then only poll for .xml

Maybe someone else can offer a better solution.

...

My guess is that a rename is faster then a write.


Have you had trouble, or just anticipating trouble?
 
S

Stephany Young

Simply have your 'pick-up' app retry the open file operation until it can
gain exclusive access and then you are certain that the 'creator' app has
closed it.
 
R

Rich P

One more thing you could do is to write the xml file as xml but it will
have one name during the writing. After the main app has completed
writing the xml file, then rename it to something that the target app
would look for. If you write it as text, you won't have the xml tags.
So I would stay with the xml write. And another thing as long as you
are always picking up an xml file with the same name each time is to
check the create date of the file on the target app. This will help
prevent picking up the same file multiple times (unless you are already
deleting the file after you pick it up). Either way, it is always a
good practice to check the create date when picking up the same named
file.

Rich
 
S

Scott McNair

Either way, it is always a good practice to check the create date when
picking up the same named file.

Unfortunately it will be several small files, named as AXyymmddxxxxxx.ax,
where xxxxxx is a six-digit counter that increments from 000001 to 999999
and then back to 000001 again. In other words there's the technical
possibility of having a million files, although realistically that's NOT
going to happen.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top