Community Forums Archive

Go Back

Subject: Importing files from list not marked as dirty
Posted by: Kit
Date: 6/23/2014 12:33:31 AM

I have the following code that inserts files found in a list. It works but the problem is that the file with the imports is not being marked as dirty so if it is closed there is no warning and the imports are lost. Does anyone have any ideas for a cure? Thanks

using System;
using System.Windows.Forms;
using System.IO;
using SoundForge;

public class EntryPoint {
public void Begin(IScriptableApp app) {

ISfFileHost openFile = app.CurrentFile;
ISfDataWnd wnd = app.ActiveWindow;
long currentPos = wnd.Cursor;
long startingPos = wnd.Cursor;

string Path = @"D:\Sony Sound Forge\importList.txt";
if (File.Exists(Path))
{
string line;

// Read the file and display it line by line.
System.IO.StreamReader file =
new System.IO.StreamReader(Path);
while((line = file.ReadLine()) != null)
{
string strPaste = line;
//MessageBox.Show(strPaste,"File Names");
ISfFileHost fileToPasteFrom = app.OpenFile(strPaste, false, false);
long mPos = fileToPasteFrom.Length;
openFile.ReplaceAudio(new SfAudioSelection(currentPos, 0), fileToPasteFrom, new SfAudioSelection(fileToPasteFrom));
currentPos = currentPos + mPos;
openFile.WaitForDoneOrCancel();
}
file.Close();

wnd.SetCursorAndScroll(startingPos, DataWndScrollTo.NoMove);
}
else
{
MessageBox.Show("No File Selected","Paste Aborted!");
}



}


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, object o) { ForgeApp.OutputText(String.Format(fmt,o)); }
public static void DPF(string fmt, object o, object o2) { ForgeApp.OutputText(String.Format(fmt,o,o2)); }

} //EntryPoint

Message last edited on 6/23/2014 12:34:04 AM by Kit.

Go Back