Simple SSIS to check if file exists, always gets false (no file exits)

  • hristo1977 (5/28/2014)


    Hi,

    Thanks for that. I got quite a few errors when pasting in that, do I miss a namespace?

    using System;

    using System.Data;

    using Microsoft.SqlServer.Dts.Runtime;

    using System.Windows.Forms;

    using System.IO;

    Regards

    H

    Looks like VB to me and you are using C#:hehe:

    Can you confirm that the if (File.Exists(filelocation) == true) row always evaluates to False?

    Is d: a local drive on the machine where the package is running?

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • That is vb.net code, if you are using C# then you need to change it, unfortunately I cannot do it at the moment.

    😎

  • LOL 😛

    Yes, I can.

    The drive is a local drive, but the package runs on C:.

    D is a drive used for SQL Server.

    Regards

    H

  • It's probably irrelevant, but do you realise that your variable is called 'FileExits' in the code, rather than 'FileExists'?

    I'm running out of ideas, sorry. This is so simple, it should work without any pain.

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • Close enough:

    D:\hristo>dir

    Volume in drive D is DATA

    Volume Serial Number is C298-D089

    Directory of D:\hristo

    2014-05-28 08:37 <DIR> .

    2014-05-28 08:37 <DIR> ..

    2014-05-08 15:42 9 emps.txt.txt

    1 File(s) 9 bytes

    2 Dir(s) 125 147 742 208 bytes free

    D:\peter>dir

    Volume in drive D is DATA

    Volume Serial Number is C298-D089

    Directory of D:\hristo

    2014-05-28 14:15 <DIR> .

    2014-05-28 14:15 <DIR> ..

    2014-05-08 15:42 9 emps.txt

    1 File(s) 9 bytes

    2 Dir(s) 125 147 742 208 bytes free

    Thanks for all your help, I have learned alot! 🙂

    Regards

    H

  • emps.txt.txt?

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • For some reason, the file had .txt.txt and my code was looking for .txt....

  • hristo1977 (5/28/2014)


    For some reason, the file had .txt.txt and my code was looking for .txt....

    My guess would be that you'd chosen not to display known file extensions in Explorer - we've all done it.

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

Viewing 8 posts - 16 through 22 (of 22 total)

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