예제 #1
0
 /// <summary>
 /// The entry point of the algorithm
 /// </summary>
 static public void Start()
 {
     //Initializing BaseOperations
     BaseOperations.Initlaize("AudiosInfo.txt", "readme.txt");
     //Iterate through files
     foreach (FileDescription file in BaseOperations.Files)
     {
         bool FoundFolder = false;
         //iterate through folders
         foreach (FolderDescription folder in BaseOperations.Folders)
         {
             //check the file duration if it fits in the folder
             if (folder.CheckLength(file.Duration))
             {
                 FoundFolder           = true;
                 folder.CurrentLength += file.Duration;
                 BaseOperations.MoveFile(file, folder);
                 break;
             }
         }
         //if there is no folder a new one will be created
         if (!FoundFolder)
         {
             FolderDescription folder = BaseOperations.ConstructFolder();
             if (!folder.CheckLength(file.Duration))
             {
                 throw new ArgumentOutOfRangeException("File size is larger than max folder size");
             }
             folder.CurrentLength += file.Duration;
             BaseOperations.MoveFile(file, folder);
         }
     }
 }
예제 #2
0
    static public FolderDescription ConstructFolder()
    {
        // Specify the directory you want to manipulate.
        // Always Change it on yor PC
        //Creating Folder With Numbers
        string path = @"C:\Users\Mostafax\Documents\GitHub\Sound-Packing-\SoundPacking\SoundPacking\bin\Debug\OUTPUT\" + i;

        i++;
        // Try to create the directory.
        DirectoryInfo     di = Directory.CreateDirectory(path);
        FolderDescription f  = new FolderDescription()
        {
            Name          = i.ToString(),
            MaxLength     = 100, //Max Space in One Folder
            CurrentLength = 0,
        };

        folders.Add(f);
        // Returning the folder
        return(f);
    }
예제 #3
0
 /// <summary>
 /// move the files to the folder
 /// </summary>
 /// <param name="SouceFile">
 /// A FileDescription object containing the description of the source file that is meant to be moved
 /// </param>
 /// <param name="DestinationFolder">
 /// A FolderDescription object containing the description of the target folder that the file will be moved to
 /// </param>
 static public void MoveFile(FileDescription SouceFile, FolderDescription DestinationFolder)
 {
     throw new NotImplementedException();
 }