Click here to Skip to main content
15,905,874 members
Home / Discussions / C#
   

C#

 
GeneralRe: Need to compare textbox with list created by me and then redirect somewhere if successful. Pin
Eddy Vluggen17-Jun-18 7:01
professionalEddy Vluggen17-Jun-18 7:01 
GeneralRe: Need to compare textbox with list created by me and then redirect somewhere if successful. Pin
#realJSOP17-Jun-18 7:03
professional#realJSOP17-Jun-18 7:03 
GeneralRe: Need to compare textbox with list created by me and then redirect somewhere if successful. Pin
Eddy Vluggen17-Jun-18 7:10
professionalEddy Vluggen17-Jun-18 7:10 
QuestionC# Process Start Time & Run Duration. Pin
Member 1387227913-Jun-18 21:51
Member 1387227913-Jun-18 21:51 
AnswerRe: C# Process Start Time & Run Duration. Pin
BillWoodruff13-Jun-18 22:33
professionalBillWoodruff13-Jun-18 22:33 
AnswerRe: C# Process Start Time & Run Duration. Pin
Jochen Arndt13-Jun-18 23:28
professionalJochen Arndt13-Jun-18 23:28 
Questionhelp plz Pin
Member 1387054413-Jun-18 19:34
Member 1387054413-Jun-18 19:34 
AnswerRe: help plz Pin
Eddy Vluggen14-Jun-18 0:39
professionalEddy Vluggen14-Jun-18 0:39 
AnswerRe: help plz Pin
User 418025414-Jun-18 7:00
User 418025414-Jun-18 7:00 
QuestionRe: help plz Pin
Gerry Schmitz14-Jun-18 7:45
mveGerry Schmitz14-Jun-18 7:45 
AnswerRe: help plz Pin
#realJSOP17-Jun-18 5:11
professional#realJSOP17-Jun-18 5:11 
AnswerRe: help plz Pin
aparnalakshmi17-Jul-18 1:04
aparnalakshmi17-Jul-18 1:04 
QuestionHow can I deserialize/Load Different XML files? Pin
SebGM201813-Jun-18 17:38
SebGM201813-Jun-18 17:38 
AnswerRe: How can I deserialize/Load Different XML files? Pin
Richard MacCutchan13-Jun-18 21:48
mveRichard MacCutchan13-Jun-18 21:48 
GeneralRe: How can I deserialize/Load Different XML files? Pin
SebGM201814-Jun-18 10:51
SebGM201814-Jun-18 10:51 
GeneralRe: How can I deserialize/Load Different XML files? Pin
Richard MacCutchan14-Jun-18 21:31
mveRichard MacCutchan14-Jun-18 21:31 
GeneralRe: How can I deserialize/Load Different XML files? Pin
SebGM201814-Jun-18 10:52
SebGM201814-Jun-18 10:52 
QuestionUsing Email Retrieval (EAGetMail) in Unity Pin
Member 1387162013-Jun-18 8:53
Member 1387162013-Jun-18 8:53 
AnswerRe: Using Email Retrieval (EAGetMail) in Unity Pin
Gerry Schmitz13-Jun-18 10:34
mveGerry Schmitz13-Jun-18 10:34 
QuestionMoving File to corresponding folders Pin
SanjaV 13-Jun-18 8:16
SanjaV 13-Jun-18 8:16 
0
down vote
favorite
I need to write a code in script component in SSIS that will move files to corresponding folders. Files that I'm getting are usually named, for example "Dem323_04265.45.23.4", "Dem65_459.452.56", "Ec2345_456.156.7894" and I need to move them to a corresponding folders. The name of my folders are "Oklahoma City (323)", "New York(65)".. I need to move those files to matching folders, so for example "Dem323_04265.45.23.4" would go to folder "Oklahoma City (323)". I need to modify my code so the number that is located between first two or three letter and underline matches number located in parenthesis. I've been working on this for several days already and I'm new with ssis and c#, so any help would be appreciated. This is the code I have so far:

public void Main()
    {
        string filename;
       // string datepart;
        bool FolderExistFlg;
        filename = Dts.Variables["User::FileName"].Value.ToString();
        // datepart = (filename.Substring(filename.Length - 12)).Substring(0, 8);
        var folderNumber = Regex.Match(
            filename,

    //Dts.Variables["OutputMainFolder"].Value.ToString(),
                    @"\(([^)]*)\)").Groups[1].Value;
        FolderExistFlg = Directory.Exists(Dts.Variables["OutputMainFolder"].Value.ToString() + "\\" + folderNumber);

        if (!FolderExistFlg)
        {
            Directory.CreateDirectory(Dts.Variables["OutputMainFolder"].Value.ToString() + "\\" + folderNumber);
        }

        File.Move(Dts.Variables["SourceFolder"].Value.ToString() + "\\" + filename + "\\" + folderNumber,
        Dts.Variables["OutputMainFolder"].Value.ToString()  + "\\" + filename);
        Dts.TaskResult = (int)ScriptResults.Success;
    }

    #region ScriptResults declaration

    enum ScriptResults
    {
        Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
        Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
    };
    #endregion

}
}

AnswerRe: Moving File to corresponding folders Pin
BillWoodruff13-Jun-18 22:41
professionalBillWoodruff13-Jun-18 22:41 
AnswerRe: Moving File to corresponding folders Pin
User 418025414-Jun-18 7:02
User 418025414-Jun-18 7:02 
Questionthe code c# below that does not compile Pin
Member 1366398513-Jun-18 6:06
Member 1366398513-Jun-18 6:06 
AnswerRe: the code c# below that does not compile Pin
OriginalGriff13-Jun-18 6:19
mveOriginalGriff13-Jun-18 6:19 
GeneralRe: the code c# below that does not compile Pin
Member 1366398513-Jun-18 16:10
Member 1366398513-Jun-18 16:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.