Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,005 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,352 people online right now. Registration is fast and FREE... Join Now!




pathing to a newly created directory

 
Reply to this topicStart new topic

pathing to a newly created directory

tootypegs
13 Jan, 2008 - 11:15 AM
Post #1

D.I.C Head
**

Joined: 9 Oct, 2007
Posts: 177


My Contributions
Hi, i have included the main parts of my code to give an idea of whats going on. Bascally within an if statement i make a folder at path 'OUTPUT_Folder_name'. I then test that is open and even when i go and search for it it does get created. However when i use 'OUTPUT_Folder_name' as the new path name for the 'ofstream' later in the code it won't write anything into the newly created folder and it should be writing files to it.

Can anyone offer a suggestion as to what i'm doing wrong?

I hope ive explained what im trying to do well enough


CODE


(if val=1)
{
        string my_string1 = "c:\\temp\\mine\\";
    string my_string3 = FILE_NAME1;
    string OUTPUT_Folder_name = my_string1 + my_string3;

    mkdir(OUTPUT_Folder_name.c_str());
    
    struct stat info;
    int Z = stat(OUTPUT_Folder_name.c_str(),&info);
    
    if (Z == 0)
    {
    
        
        
    char *buffer = new char[Size_of_the_file1];
    ifstream myFile ("C:\\temp\\usbimage4.txt", ios::in | ios::binary);
    myFile.seekg (start_byte1,std::ios::beg);

    
    myFile.read(buffer, Size_of_the_file1*sizeof(char));
  

    ofstream g(OUTPUT_Folder_name.c_str(), ios::out | ios::binary);
    
    
    g.write(buffer, Size_of_the_file1*sizeof(char));
       g.close();

        

        }
}



Thank you
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 12:41PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month