March 30, 2010 at 8:59 am
Hi,
I am using script task in my package. Here i want to add date to newly created folder, like "folder-30\03\2010" . Using following code i am getting folder name as "Folder-30".
Can you anybody suggest me how to get output as like "Folder-30\03\2010"
Public Sub Main()
Dim FileDate, InFolderName As String
Dim strDay, strMonth, strYear As String
InFolderName = Dts.Variables("User::InFolderName").Value.ToString()
InFolderName.Trim()
strDay = DateTime.Now.Day.ToString()
strMonth = DateTime.Now.Month.ToString()
strYear = DateTime.Now.Year.ToString()
FileDate = "-" + strDay + "\" + strMonth + "\" + strYear
InFolderName = InFolderName + FileDate
MessageBox.Show(InFolderName.ToString())
Dts.Variables("User::InFolderName").Value = InFolderName
Dts.TaskResult = Dts.Results.Success
End Sub
March 30, 2010 at 9:09 am
Folder names cannot contain slashes. Try replacing slash with - and you should have more luck.
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
March 30, 2010 at 9:15 am
Replace "+" with "&" that should do it
FileDate = "-" & strDay & "\" & strMonth & "\" & strYear
March 30, 2010 at 9:22 am
Wrong. File names and folder names cannot contain slashes.
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
March 30, 2010 at 9:31 am
Phil Parkin (3/30/2010)
Wrong. File names and folder names cannot contain slashes.
🙂 I agree with you on that Phill, I was just trying to help him with the code their.. because using "+" was just getting him part of the name and If I understand correctly he wasn't able to get the Complete Folder Name as he was expecting in the "message box"
FileDate = "-" + strDay + "\" + strMonth + "\" + strYear
InFolderName = InFolderName + FileDate
MessageBox.Show(InFolderName.ToString())
Dts.Variables("User::InFolderName").Value = InFolderName
March 30, 2010 at 9:33 am
divyanth (3/30/2010)
Phil Parkin (3/30/2010)
Wrong. File names and folder names cannot contain slashes.🙂 I agree with you on that Phill, I was just trying to help him with the code their.. because using "+" was just getting him part of the name and If I understand correctly he wasn't able to get the Complete Folder Name as he was expecting in the "message box"
FileDate = "-" + strDay + "\" + strMonth + "\" + strYear
InFolderName = InFolderName + FileDate
MessageBox.Show(InFolderName.ToString())
Dts.Variables("User::InFolderName").Value = InFolderName
Sorry. Blood pressure too high 🙂 Think I'll take a break...
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
March 30, 2010 at 10:07 am
Thank you all.
Following code working fine for me
FileDate = "-" + strDay + strMonth + strYear
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply