how to move files with no extensions

  • Hello,

    i have a small issue, i am trying to move files from source to destination, and there are 20-40 files, which can fluctuate depending on day of the week. the big problem i am having is, i cant seem to get it to work because the files have no extension, so i tried to use *.* in the foreach under Files option... however that never works, any ideas or solution?

    thanks in advance

  • sorry also, i am using SSIS 2015, and using foreach for all files (depending the quantity), and within foreach i am using file system task... any help please 🙂

  • Can't you just use * ?

  • Thank you ZZartin for the response, i tried to use *
    however i get:
    Error: 0xC002F304 at File System Task, File System Task: An error occurred with the following error message: "Could not find file '\\sharedrive\FilesToMove\'.".
    Task failed: File System Task
    Warning: 0x80019002 at Foreach File, Move it!: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (1) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.

    I tried to use Fully Qualified, or Name, and name and extension plus checked the checkbox "Traverse Subfolders" and tried without check, still same error message 🙁

  • use a script task instead of a file system task;

    the code would look something like this:


    string WorkingDirectory = (string)Dts.Variables["WorkingDirectory"].Value;
          string ArchiveDirectory = (string)Dts.Variables["ArchiveDirectory"].Value;
          if (System.IO.Directory.Exists(WorkingDirectory))
          {
           foreach (string filename in System.IO.Directory.GetFiles(WorkingDirectory))
           {
            string JustTheFileName = System.IO.Path.GetFileName(filename);
            if (string.IsNullOrEmpty(System.IO.Path.GetExtension(filename)))
            {
              System.IO.File.Move(filename, System.IO.Path.Combine(ArchiveDirectory, JustTheFileName);
            }
           }
          }

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • big thanks Lowell, i will roll with that solution 🙂

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply