Пример #1
0
 void SetFtpMusicFolders(MusicDataBase mdb, FtpServer ftpServer)
 {
     lock (ftpServer.RootFolders)
     {
         ftpServer.RootFolders.Clear();
         foreach (var dir in mdb.MusicFolders)
         {
             try
             {
                 FileSystem.GetFileSystemEntries(dir);
                 string name         = Path.GetFileNameWithoutExtension(dir);
                 int    i            = 0;
                 string selectedName = name;
                 while (!ftpServer.RootFolders.TryAdd(selectedName, dir))
                 {
                     selectedName = name + (++i);
                 }
                 this.LogDebug("Added root <cyan>{0}<default> {1}", selectedName, dir);
             }
             catch (Exception ex)
             {
                 this.LogWarning(ex, "Cannot access folder {0}", dir);
             }
         }
         ftpServer.DisconnectAllClients();
     }
 }