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

System.IO.IOException: The process cannot access the file because it is being used by another process.

$
0
0

hi there, I've created a script component to log every single processed row and store values in a log file on the server.  Below is the code inside the ProcessInput

    public override void ProcessInput(int InputID, PipelineBuffer Buffer)   //this method will output each column value during run time for each buffer load 
    {

        log_path = @"c:\" + this.Variables.varapplicationName;

        log_file = log_path + "\\" + DateTime.Now.ToString("yyyyMMdd") + ".log"; 

        if (!File.Exists(log_path))  // if file path does not exit, creat one.  HS Feb.20/2013
        {
            Directory.CreateDirectory(log_path);

            File.CreateText(log_file);

        }
        StreamWriter tw = File.AppendText(log_file);


        while (Buffer.NextRow())
        {
            for (int columnIndex = 0; columnIndex < Buffer.ColumnCount; columnIndex++)
            {

                tw.Write(Buffer[columnIndex] + " | ");


            }
            tw.WriteLine();
        }

        tw.Close();

        base.ProcessInput(InputID, Buffer);


    }
}
however, it keeps telling me 

System.IO.IOException: The process cannot access the file because it is being used by another process.

Any comments on this  one? 

Thanks



--Currently using Reporting Service 2000; Visual Studio .NET 2003; Visual Source Safe SSIS 2008 SSAS 2008, SVN --


Viewing all articles
Browse latest Browse all 24688

Trending Articles



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