Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Loop through .xls, .doc, & .txt in one folder. Copy to 3 different folders.

$
0
0

Here's my setup.

I've got the script like this:

		public void Main()
		{
			// TODO: Add your code here

            if (System.IO.Path.GetExtension(Dts.Variables["strSourceFile"].Value.ToString()) == ".xls")
            {
                System.IO.File.Move(Dts.Variables["strSourceFile"].Value.ToString(), Dts.Variables["EXCEL"].Value.ToString() + System.IO.Path.GetFileName(Dts.Variables["strSourceFile"].Value.ToString()));
            }
            else if (System.IO.Path.GetExtension(Dts.Variables["strSourceFile"].Value.ToString()) == ".xlsx")
            {
                System.IO.File.Move(Dts.Variables["strSourceFile"].Value.ToString(), Dts.Variables["EXCEL"].Value.ToString() + System.IO.Path.GetFileName(Dts.Variables["strSourceFile"].Value.ToString()));
            }
            else if (System.IO.Path.GetExtension(Dts.Variables["strSourceFile"].Value.ToString()) == ".txt")
            {
                System.IO.File.Move(Dts.Variables["strSourceFile"].Value.ToString(), Dts.Variables["TEXT"].Value.ToString() + System.IO.Path.GetFileName(Dts.Variables["strSourceFile"].Value.ToString()));
            }
            else if (System.IO.Path.GetExtension(Dts.Variables["strSourceFile"].Value.ToString()) == ".doc")
            {
                System.IO.File.Move(Dts.Variables["strSourceFile"].Value.ToString(), Dts.Variables["WORD"].Value.ToString() + System.IO.Path.GetFileName(Dts.Variables["strSourceFile"].Value.ToString()));
            }
            Dts.TaskResult = (int)ScriptResults.Success;

		}


Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>