Example #1
0
        /// <summary>
        /// Export specified track items
        /// </summary>
        /// <param name="trackItems"></param>
        /// <param name="packName"></param>
        /// <param name="targetFolder"></param>
        private static void _ExportTracks(IEnumerable <ListViewItem> trackItems, string packName, string targetFolder)
        {
            if (trackItems != null && !string.IsNullOrEmpty(packName) && !string.IsNullOrEmpty(targetFolder) && Directory.Exists(targetFolder))
            {
                // Directories
                string packFolder    = string.Concat(targetFolder, @"\", File2.GetValidFileName(packName, true));
                string tracksFolder  = string.Concat(packFolder, LibraryConstants.FOLDER_TRACKS);
                string defaultFolder = string.Concat(packFolder, LibraryConstants.FOLDER_DEFAULT);

                Directory.CreateDirectory(packFolder);
                Directory.CreateDirectory(tracksFolder);

                // Libraries
                string frameworkFileName = string.Concat(Tools.WorkingPath, DjeFramework1.LibraryProperties.FILE_LIBRARY);
                string tduLibFileName    = string.Concat(Tools.WorkingPath, TDUModdingLibrary.LibraryProperties.FILE_LIBRARY);

                File.Copy(frameworkFileName, string.Concat(packFolder, DjeFramework1.LibraryProperties.FILE_LIBRARY), true);
                File.Copy(tduLibFileName, string.Concat(packFolder, TDUModdingLibrary.LibraryProperties.FILE_LIBRARY), true);

                // EXE files
                string tpFileName = string.Concat(Tools.WorkingPath, LibraryConstants.FOLDER_TRACKS, AppConstants.FILE_EXE_TRACKPACK);

                File.Copy(tpFileName, string.Concat(packFolder, AppConstants.FILE_EXE_TRACKPACK), true);

                // Exported tracks
                foreach (ListViewItem anotherItem in trackItems)
                {
                    DFE customTrack = anotherItem.Tag as DFE;

                    if (customTrack != null)
                    {
                        FileInfo fi = new FileInfo(customTrack.FileName);
                        File.Copy(customTrack.FileName, string.Concat(tracksFolder, @"\", fi.Name), true);
                    }
                }

                // Default challenges
                File2.CopyDirectory(string.Concat(Tools.WorkingPath, LibraryConstants.FOLDER_XML, LibraryConstants.FOLDER_DEFAULT, LibraryConstants.FOLDER_CHALLENGES), defaultFolder);
            }
        }