Subject:DumpRegionsToFiles - splitting Region names
Posted by: sound-kobo
Date:1/11/2007 7:58:25 PM
Hello, I posted before about making region info into XML for use in Flash. Many thanks for the point in the right direction. :) So far so good, except I can't figure out how to split the region names. Each region is named something like "hello; greeting" ,etc. I modified the DumpRegionsToFiles.cs script "WriteMarkersTo Stream" function as follows, in an attempt to split marker/region names that are separated by a semicolon... and output the results in XML format. ________________________________________________________ public void WriteMarkersToStream(StreamWriter stm, ISfFileHost file) { stm.WriteLine(String.Format("<totalMarkers>{0} </totalMarkers>", file.MarkerCount)); stm.WriteLine(String.Format("<fullPath>{0}</fullPath>", file.Filename)); ISfPositionFormatter PosFmt = file.Formatter; int ii = 0; foreach (SfAudioMarker mk in file.Markers) { string nm = mk.Name; string[] arMkrNm = new string[2]; char[] splitter = {';'}; arMkrNm = nm.Split(";"); stm.WriteLine("<marker{0}>", mk.Ident); stm.WriteLine(" <name>{0}</name>", arMkrNm[0]); stm.WriteLine(" <type>{0}</type>", arMkrNm[1]); stm.WriteLine(" <startPoint>{0}</startPoint>", PosFmt.Format(mk.Start)); stm.WriteLine(" <length>{0}</length>", PosFmt.Format(mk.Length)); stm.WriteLine("</marker{0}>", mk.Ident); ++ii; } stm.WriteLine(""); stm.Flush(); ______________________________________________________________ The compiler returns the following error: "The best overloaded method match for 'string.Split(params char[])' has some invalid arguments" |
Subject:RE: DumpRegionsToFiles - splitting Region nam
Reply by: _TJ
Date:1/12/2007 1:38:01 PM
use arMkrNm = nm.Split(splitter); instead of arMkrNm = nm.Split(";"); |
Subject:RE: DumpRegionsToFiles - splitting Region nam
Reply by: sound-kobo
Date:1/12/2007 7:57:19 PM
gotcha... works now. Many thanks!! I'm pretty new to all this, and am finding loads of good information looking back through past threads on this forum. New information = new questions... 1. How can I split the region name and then loop through the array to find out how many items it has, writing a separate XML tag for each one? I assume it will be something like: int i=1; foreach (string item in arMkrNm) { stm.WriteLine(" <name{i}>{0}</name{i}>", arMkrNm); ++i; } 2. "file.Filename" gets the entire path to the file. Is there an easy way just to get the filename minus the path? or do I have to split the path into an array, separated by "/" and then just choose the last item? I can't seem to find info about this in the documentation... Thanks again!! Wes Message last edited on1/12/2007 8:38:50 PM bysound-kobo. |
Subject:RE: DumpRegionsToFiles - splitting Region nam
Reply by: sound-kobo
Date:1/12/2007 9:07:06 PM
I figured out the answer to both questions... things are getting clearer.. int i=1; foreach (string item in arMkrNm) { stm.WriteLine(" <name{1:d2}>{0}</name{1:d2}>", item, i); ++i; } and after looking back at previous threads... i found this.. // how to get the filename and path name //The Path class is part of the .NET runtime, and provides methods for breaking a pathname up //into it's parts and combining them back together. string strFullFilePathName = file.Filename; string strDirectory = Path.GetDirectoryName(strFullFilePathName); string strFilename = Path.GetFileName(strFullFilePathName); Thanks for this great forum!! Message last edited on1/12/2007 9:59:01 PM bysound-kobo. |