locked
get filename RRS feed

  • Question

  • In ssis 2008 script task, I would like tho get the name of the file as follows but the mesasge box shown an empty string. Do you see why please? thanks

    public void Main()
            {
                Dts.Variables["FileName"].Value = System.IO.Path.GetFileName(Dts.Variables["FileName"].Value.ToString());
                MessageBox.Show(Dts.Variables["FileName"].Value.ToString());

                Dts.TaskResult = (int)ScriptResults.Success;
            }

    Friday, October 7, 2011 11:33 AM

Answers

  • For me given code is working.

    I followed the given steps:

    1. Foreach loop with File enumerator from a folder.

    2.Variable mapping of User::FileName to index 0. (Please check this step)

    3. Script task ReadOnly variable as User:FileName

    and your code is working.


    Bhoopendra Pratap Singh Please mark the post as answered if it answers your question.
    • Marked as answer by arkiboys Friday, October 7, 2011 2:25 PM
    Friday, October 7, 2011 11:57 AM

All replies

  • HI,

    Code should work fine.

    Can you please load the File name value to local script variable and try it again.

     

    Is file name is pointing to Remote path. ?

     

    Thanks & Regards,

    Naveen T


    Naveen Kumar
    Friday, October 7, 2011 11:45 AM
  • For me given code is working.

    I followed the given steps:

    1. Foreach loop with File enumerator from a folder.

    2.Variable mapping of User::FileName to index 0. (Please check this step)

    3. Script task ReadOnly variable as User:FileName

    and your code is working.


    Bhoopendra Pratap Singh Please mark the post as answered if it answers your question.
    • Marked as answer by arkiboys Friday, October 7, 2011 2:25 PM
    Friday, October 7, 2011 11:57 AM
  • if you couldn't find the problem put a Break point in the script task and follow the code line by line with F10, you can use watch window to find out variable values and what happened in the code
    http://www.rad.pasfu.com
    Friday, October 7, 2011 12:54 PM
  • Thank you all.
    Friday, October 7, 2011 2:25 PM