Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First of all, couple of things about how to use Stack Overflow.</p> <ol> <li><p>Please <strong>do not</strong> post new questions when you can just ask the person who answered your question <a href="https://stackoverflow.com/questions/7139172/how-to-create-ssis-package-which-copies-all-files-into-new-folder/7140168#7140168">How do I create a package that would copy all files from a given folder into a new folder?</a> about how to do this in C#. Also, <em>always</em> mention the <strong>version</strong> that you are using in the questions that you post.</p></li> <li><p>Please <strong>do not</strong> post your questions in answer.</p></li> </ol> <p>Anyways, here is the C# code for the VB.NET code that I posted. I have also updated the original answer to your other question <a href="https://stackoverflow.com/questions/7139172/how-to-create-ssis-package-which-copies-all-files-into-new-folder/7140168#7140168">How do I create a package that would copy all files from a given folder into a new folder?</a> to include the C# code.</p> <pre><code>public void Main() { Variables varCollection = null; Dts.VariableDispenser.LockForRead("User::SourceFilePath"); Dts.VariableDispenser.LockForRead("User::DestinationRoot"); Dts.VariableDispenser.LockForRead("User::MonthStartPosition"); Dts.VariableDispenser.LockForRead("User::MonthLength"); Dts.VariableDispenser.LockForRead("User::MonthNameFormat"); Dts.VariableDispenser.LockForWrite("User::DestinationFolder"); Dts.VariableDispenser.GetVariables(ref varCollection); string SourceFilePath = varCollection["User::SourceFilePath"].Value.ToString(); string FileName = SourceFilePath.Substring(SourceFilePath.LastIndexOf('\\') + 1); string DestinationRoot = varCollection["User::DestinationRoot"].Value.ToString(); int MonthStartPosition = Convert.ToInt32(varCollection["User::MonthStartPosition"].Value); int MonthLength = Convert.ToInt32(varCollection["User::MonthLength"].Value); int MonthValue = 0; string MonthNameFormat = varCollection["User::MonthNameFormat"].Value.ToString(); string FolderName = string.Empty; string MonthwiseDirectory = string.Empty; if (MonthStartPosition &gt; 0 &amp;&amp; MonthLength &gt; 0) { MonthValue = Convert.ToInt32(FileName.Substring(MonthStartPosition - 1, MonthLength)); } if (FileName.Length &gt; 0 &amp;&amp; MonthValue &gt; 0) { FolderName = new DateTime(1, MonthValue, 1).ToString(MonthNameFormat); } MonthwiseDirectory = System.IO.Path.Combine(DestinationRoot, FolderName); if (!System.IO.Directory.Exists(MonthwiseDirectory)) { System.IO.Directory.CreateDirectory(MonthwiseDirectory); } varCollection["User::DestinationFolder"].Value = MonthwiseDirectory; Dts.TaskResult = (int)ScriptResults.Success; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload