Как создать другое имя файла? - PullRequest
0 голосов
/ 21 апреля 2020
void Splitfile(string sourcefile, string destinationfile, int numberParts, unsigned long int sizeOfPart) {
    ifstream fin(sourcefile, ifstream::binary);
    ofstream fout(destinationfile, ofstream::binary);
    fin.seekg(0, fin.end);
    long fileSize = fin.tellg();
    fin.seekg(0, fin.beg);
    unsigned long int numberOfParts, partSize, numberOfBytesForLastPart;
    if (numberParts > 0) {

        // Part number was given
        if (fileSize % (fileSize / numberParts) != 0)
         // Write a file with less then part size bytes
        // Therefore, decrement the number of output files with full number of bytes
            numberOfParts = numberParts - 1;
        else {
            // Write numberParts files with equal number of bytes
            numberOfParts = numberParts;
        }
        partSize = fileSize / numberOfParts;       
        numberOfBytesForLastPart = fileSize % partSize;    // The number of bytes for the last file
    }
    else {
        // The size of a part was given
        partSize = sizeOfPart;
        numberOfParts = fileSize / sizeOfPart;
        numberOfBytesForLastPart = fileSize % partSize; // The size of the last file
    }
//here is my problem....
    for (int i = 0;i <= numberOfParts;++i) {
        ofstream filename;
        i = sourcefile << "-part0" << i + 1;
        CopyFile(sourcefile, filename);
    }
    fout.close();
    fin.close();
}

MYSPLITFILE -s path_of_source_file -d path_of_destination -numpart x

x - положительное целое число, количество разделенных частей.

Я закончил обработку деления файла

  • ПОМОГИТЕ МНЕ СОЗДАТЬ ИМЯ ФАЙЛА fim.01, fim.02 в месте назначения файла
    • Пример: MYSPLITFILE -s D: / fim -d D: / Flo numpart 3 ==> В файле flo будет файл fim.01, fim.02, fim.03

, но я не могу создать новый файл, подобный этому: <пожалуйста, помогите мне. </p>

...