October 7, 2019 at 8:34 pm
public void Main()
{
// TODO: Add your code here
string filePrefix;
filePrefix = @"\\xxx\xxx\Data\xxx\attachments\";
string filePath;
filePath = filePrefix + (string)Dts.Variables["tempSource"].Value;
if (File.Exists(filePath))
{
Dts.Variables["FileExists"].Value = true;
}
else
{
Dts.Variables["FileExists"].Value = false;
}
Dts.TaskResult = (int)ScriptResults.Success;
}
And still filePath value turns out to be \\\\xxx\\xxx\\Data\\xxx\\attachments\\somefile.txt
How can I prevent this? The file is not found with the extra backslashes. When I paste the true URL into windows explorer it is found
October 7, 2019 at 8:56 pm
I'm curious how the string is formed when you combine those 2 values.
And still filePath value turns out to be \\\\xxx\\xxx\\Data\\xxx\\attachments\\somefile.txt
How do you know this is the actual value? Output from script?
I assume the explicit cast (string) is the same as .ToString() method, but not sure. Is it possible the explicit cast is giving you something weird like the literal string: "Object"
What if you had a variable in your package or better yet a Parm and you pass it in to the script. I mean you would never hard code something like that in a script anyway. Maybe that will solve your problem.
October 7, 2019 at 9:30 pm
Long story short... values come from a SQL task and are passed to a for each container as an ADO resultset.
Seems the paths are working after all and it was something else that was the issue!
When I hit the breakpoint I hover over value and that is when I see the double up of backslashes but when the path is passed to an FTP task then all is well.
As a side note, when I add a breakpoint within main() (in the script task) the debugger opens the script editing window each time the breakpoint is hit. I F11 through the loop and then the script editing window closing again. Then it opens again as soon as it hits the breakpoint in the next loop and so we go on for every iteration of the loop. This slows things down greatly.
Is there a way to tel Visual Studio 2019 to stop closing the code editor window each time?
October 7, 2019 at 9:48 pm
Cool, glad it's working.
As for the editor window, i doubt it, since that script unloads on each loop so there would be no reference to it.
I like to use message boxes if you just want to monitor values. You can loop pretty fast that way.. its an option if you just want to see a value of something.
October 7, 2019 at 9:53 pm
Re: MessageBox.
Great tip, thankyou! I was debugging purely to see the value of a variable for each loop. I had no idea the IDE could present message boxes. It was worth getting out of bed this morning!
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply