ive got it to compile but it returns an error message still when it runs, i wonder if anyone can assist, i must be close now to solving this.
using System;
using System.IO;
using System.Windows.Forms;
using System.Collections.Generic;
using SoundForge;
using System.Text.RegularExpressions;
// Adds regions every 16 seconds to an open audio file. 
// Exports every odd region to a user supplied output directory in the same format as the original open audio file.
public class EntryPoint
{
    public void Begin(IScriptableApp app)
    {
        // select the output directory for the exported regions
        string outDirectory = SfHelpers.ChooseDirectory("Choose the output directory.", @"C:\");
        ISfFileHost work_file = app.CurrentFile;
        // File extension for naming the ouput files
        string outExt = work_file.SaveFormat.Extension;
        // undo wrapper for this script.
        int scriptUndo = work_file.BeginUndo("ScriptUndo");
        SfAudioSelection asel = new SfAudioSelection(work_file);
        SfAudioMarkerList mark_list = work_file.Markers;
        // clear any existing regions
        mark_list.Clear();
        long file_length = asel.Length;
        double lengthLeft = work_file.Formatter.PositionToTime(file_length);
        long regionLength = work_file.Formatter.TimeToPosition(16);
        long currentPos = work_file.Formatter.TimeToPosition(0);
        bool keepGoing = true;
        int regionCount = 1;
        while(keepGoing){
            // check to see if there is enough length left to add the next region
            if (lengthLeft > 8.0)
            {
                string regionName = getFileName(String.Format("Region_{0}", regionCount),app.CurrentFile.Filename);
                // add region
                mark_list.AddRegion(currentPos, regionLength, regionName);
                // export to file if this is an export region
                if (regionCount % 2 != 0)
                {
                    SfAudioSelection regionSel = new SfAudioSelection(currentPos, regionLength);
                    string saveName = Path.Combine(outDirectory, String.Format("{0}.{1}", regionName, outExt));
                    exportRegionToFile(saveName, work_file, regionSel, app);  
                }
                // update our tracking vars.
                currentPos += regionLength;
                lengthLeft -= 8.0;
                regionCount++;
            }
            // else make a region out of whatever time is leftover and set keepGoing to False
            else{
                string regionName = getFileName(String.Format("Region_{0}", regionCount),app.CurrentFile.Filename);
                regionLength = work_file.Formatter.TimeToPosition(lengthLeft);
                mark_list.AddRegion(currentPos, regionLength, regionName);
                // export to file if this is an export region
                if (regionCount % 2 != 0)
                {
                    SfAudioSelection regionSel = new SfAudioSelection(currentPos, regionLength);
                    string saveName = Path.Combine(outDirectory, String.Format("{0}.{1}", regionName, outExt));
                    exportRegionToFile(saveName, work_file, regionSel, app);
                }
                // stop our loop
                keepGoing = false;
            }
        }
        // close the undo wrapper
        work_file.EndUndo(scriptUndo, false);
    }
	
    public void exportRegionToFile(string regionName, ISfFileHost workFile, SfAudioSelection regionSelection, IScriptableApp app){
        ISfFileHost newFile = app.NewFile(workFile.DataFormat, true);
        newFile.OverwriteAudio(0, 0, workFile, regionSelection);
        newFile.SaveAs(regionName, workFile.SaveFormat.Guid, "Default Template", RenderOptions.WaitForDoneOrCancel);
        newFile.Close(CloseOptions.SaveChanges);
    }
    public void FromSoundForge(IScriptableApp app)
    {
        ForgeApp = app; //execution begins here
        app.SetStatusText(String.Format("Script '{0}' is running.", Script.Name));
        Begin(app);
        app.SetStatusText(String.Format("Script '{0}' is done.", Script.Name));
    }
    public static IScriptableApp ForgeApp = null;
    public static void DPF(string sz) { ForgeApp.OutputText(sz); }
    public static void DPF(string fmt, params object[] args) { ForgeApp.OutputText(String.Format(fmt, args)); }
public String getFileName(String n1, String n2)
{
  //  try
  //  {
        String v = "";
        switch (n1.ToLower())
        {
            case "region 1":
            default:
                v = Regex.Replace(n2, @"C\dC\d", "C1C2");
                break;
            case "region 2":
                v = Regex.Replace(n2, @"C\dC\d", "C3C4");
                break;
            case "region 3":
                v = Regex.Replace(n2, @"C\dC\d", "C5C6");
                break;
        }
     return v;
 }
  //  catch (Exception e)
   // {
        
   //     return "";
 //}
//}
} //EntryPoint