Esempio n. 1
0
        public void AddToPlaylist(string path, bool isReading)
        {
            NumberOfEntries++;
            OneFile newFile = new OneFile(path);

            if (!isReading)
            {
                string[] lines = File.ReadAllLines(this.Path);
                int      place = 0;
                foreach (string line in lines)
                {
                    place++;
                    if (line.Contains("Version"))
                    {
                        break;
                    }
                }
                if (lines[1].Contains("NumberOfEntries="))
                {
                    lines[1] = "NumberOfEntries=" + NumberOfEntries;
                }
                using (StreamWriter writer = new StreamWriter(".tempFile"))
                {
                    int i = 0;
                    foreach (string line in lines)
                    {
                        i++;
                        if (place == i)
                        {
                            int seconds = -1;
                            writer.WriteLine("File" + NumberOfEntries + "=" + newFile.Path);
                            writer.WriteLine("Title" + NumberOfEntries + "=" + newFile.Name);
                            writer.WriteLine("Length" + NumberOfEntries + "=" + seconds);
                            writer.WriteLine("");
                        }
                        writer.WriteLine(line);
                    }
                }
                File.Replace(".tempFile", this.Path, this.Path + ".bak");
                File.Delete(this.Path + ".bak");
            }
            Files.Add(newFile);
        }
Esempio n. 2
0
 public void AddToPlaylist(string path, bool isReading)
 {
     NumberOfEntries++;
     OneFile newFile = new OneFile(path);
     if (!isReading)
     {
         string[] lines = File.ReadAllLines(this.Path);
         int place = 0;
         foreach (string line in lines)
         {
             place++;
             if (line.Contains("Version"))
                 break;
         }
         if (lines[1].Contains("NumberOfEntries="))
             lines[1] = "NumberOfEntries=" + NumberOfEntries;
         using (StreamWriter writer = new StreamWriter(".tempFile"))
         {
             int i = 0;
             foreach (string line in lines)
             {
                 i++;
                 if (place == i)
                 {
                     int seconds = -1;
                     writer.WriteLine("File" + NumberOfEntries + "=" + newFile.Path);
                     writer.WriteLine("Title" + NumberOfEntries + "=" + newFile.Name);
                     writer.WriteLine("Length" + NumberOfEntries + "=" + seconds);
                     writer.WriteLine("");
                 }
                 writer.WriteLine(line);
             }
         }
         File.Replace(".tempFile", this.Path, this.Path + ".bak");
         File.Delete(this.Path + ".bak");
     }
     Files.Add(newFile);
 }