T
Tony
I've got a deal where I've wrote an app which will secure ftp reports
out to various clients. I set it up to pull key pieces of information
like ftp site etc from an xml file that has a standard layout and
accompanies each report that's run.
I have a tag for filename, but most filenames will not be static. They
will contain a date in some format that the attachment is reporting
on. Of course, various clients request filenames to be in various
patterns. So while I can create a generic ftp app, the filename
handling will need some work.
What I was thinking was letting the reports progs put the filename in
the xml file within the proper tags, with the various ways the date
can be entered within the filename and use a char that I've never seen
used in a filename as a delimiter.
I chose the caret (^) as the symbol.
I've got everything set up and am pulling the filename in as a string,
And know how to replace with a real date value but I don't know how
best to take the pieces out of the filename to change to date.
I
replace ^mm^ with mm
replace ^dd^ with yy
replace ^yyyy^ with yyyy
replace ^mmddyy^ with mmddyy
replace ^mmddyyyy^ with mmddyyyy
replace ^-dd^ with dd-1
replace ^mm-ddyy^ with mmddyy-1
replace ^mm-ddyyyy^ with mmddyyyy-1
So today, for example
filename_^mm^-^dd^-^yy^_something.zip
would be handled by the app as if
filename_09-27-06_something.zip
was passed to it from the xml file.
or
filename_^mm^_^yyyy^_something.zip
would be handled by the app as if
filename_09_2006_something.zip
was passed to it from the xml file.
and also
filename_^mm^-^-dd^-^yyyy^_something.zip
would be handled by the app as if
filename_09-26-2006_something.zip
was passed to it from the xml file.
(since the -dd would signify yesterday's day.)
What I got so far (for testing purps) for a start,,,
string tony =
"filename_^mm^-^dd^-^yy^_Something.zip";
string[] parsedData = tony.Split('^');
text1.AppendText(parsedData[1] + "\r\n");
text1.AppendText(parsedData[2] + "\r\n");
text1.AppendText(parsedData[3] + "\r\n");
text1.AppendText(parsedData[4] + "\r\n");
text1.AppendText(parsedData[5] + "\r\n");
text1.AppendText(parsedData[6] + "\r\n");
which returns
mm
-
dd
-
yy
_Something.zip
But I'm thinking Regex would be a better way to handle this and easier
to reconstruct the correct filename from.
But regex is something I don't know at all, least of all how to
auto-replace values between carats with other values
expecially when the year could be yy or yyyy
Plus, The carat is a special symbol in regex, would this strike it as
a possible char ro use my redlight?
Can one of you gurus help me finish this project??
Thanks in advance! (and sorry for the very long post.. wanted to be
sure I gave enough information)
Tony!
out to various clients. I set it up to pull key pieces of information
like ftp site etc from an xml file that has a standard layout and
accompanies each report that's run.
I have a tag for filename, but most filenames will not be static. They
will contain a date in some format that the attachment is reporting
on. Of course, various clients request filenames to be in various
patterns. So while I can create a generic ftp app, the filename
handling will need some work.
What I was thinking was letting the reports progs put the filename in
the xml file within the proper tags, with the various ways the date
can be entered within the filename and use a char that I've never seen
used in a filename as a delimiter.
I chose the caret (^) as the symbol.
I've got everything set up and am pulling the filename in as a string,
And know how to replace with a real date value but I don't know how
best to take the pieces out of the filename to change to date.
I
replace ^mm^ with mm
replace ^dd^ with yy
replace ^yyyy^ with yyyy
replace ^mmddyy^ with mmddyy
replace ^mmddyyyy^ with mmddyyyy
replace ^-dd^ with dd-1
replace ^mm-ddyy^ with mmddyy-1
replace ^mm-ddyyyy^ with mmddyyyy-1
So today, for example
filename_^mm^-^dd^-^yy^_something.zip
would be handled by the app as if
filename_09-27-06_something.zip
was passed to it from the xml file.
or
filename_^mm^_^yyyy^_something.zip
would be handled by the app as if
filename_09_2006_something.zip
was passed to it from the xml file.
and also
filename_^mm^-^-dd^-^yyyy^_something.zip
would be handled by the app as if
filename_09-26-2006_something.zip
was passed to it from the xml file.
(since the -dd would signify yesterday's day.)
What I got so far (for testing purps) for a start,,,
string tony =
"filename_^mm^-^dd^-^yy^_Something.zip";
string[] parsedData = tony.Split('^');
text1.AppendText(parsedData[1] + "\r\n");
text1.AppendText(parsedData[2] + "\r\n");
text1.AppendText(parsedData[3] + "\r\n");
text1.AppendText(parsedData[4] + "\r\n");
text1.AppendText(parsedData[5] + "\r\n");
text1.AppendText(parsedData[6] + "\r\n");
which returns
mm
-
dd
-
yy
_Something.zip
But I'm thinking Regex would be a better way to handle this and easier
to reconstruct the correct filename from.
But regex is something I don't know at all, least of all how to
auto-replace values between carats with other values
expecially when the year could be yy or yyyy
Plus, The carat is a special symbol in regex, would this strike it as
a possible char ro use my redlight?
Can one of you gurus help me finish this project??
Thanks in advance! (and sorry for the very long post.. wanted to be
sure I gave enough information)
Tony!