2012-10-10 2 views
-1

나는 재미를 위해이 응용 프로그램을 만들고 있어요와 별도의 라인을 만들려면하지만 난 문제어떻게 C#을 (TEXTFILE)

내가이 문자열/파일이 별도의 라인을 읽을 수 할 수 있습니다.

이 파일 (이 아닌 전체 파일) :

1ChampSelectPack.Ahri.mp31ChampSelectPack.Akali.mp31ChampSelectPack.Alistar.mp31ChampSelectPack.Amumu.mp31ChampSelectPack.Anivia.mp31ChampSelectPack.Annie.mp31ChampSelectPack.Ashe.mp31ChampSelectPack.Blitzcrank.mp31ChampSelectPack.Brand.mp31ChampSelectPack.Caitlyn.mp3 

이 내가 지금까지 무엇을 가지고 있습니다 :

  List<SoundPath> paths = new List<SoundPath>(); 
      StreamReader reader = File.OpenText("C:/Users/Esat/Documents/Visual Studio 2010/Projects/WikiLoL/WikiLoL/lolSoundBoard/1ChampSelectPack/files.txt"); 

      while (!reader.EndOfStream) 
      { 

       SoundPath path = new SoundPath(); 
       path.Path = reader.ReadLine(); 
       paths.Add(path); 
      } 

      reader.Close(); 

      return paths; 
+0

어떻게 분리 되길 원하십니까? – derape

+1

예상 출력보기 – Reniuz

답변

1

당신이 할 수있는 그것은 .MP3 및 추가 .MP3에 분할을 사용하여 결과 어레이의 각 요소에. 즉, 당신이 원하는 경우

string text = File.ReadAllText("C:/Users/Esat/Documents/Visual Studio 2010/Projects/WikiLoL/WikiLoL/lolSoundBoard/1ChampSelectPack/files.txt"); 
string[] lines = text.Split(new string[] { ".mp3" }, StringSplitOptions.RemoveEmptyEntries); 
for (int i = 0; i < lines.Length; i++) 
    lines[i] = lines[i] + ".mp3"; 
2

확실하지 :

"YourString".Split(new string[] {"mp3"}, StringSplitOptions.None) 

당신은 이후 각 행의 "MP3"를 추가해야합니다.