Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3046

crashing on fstream open file

$
0
0
other posts talk about the fopen function and don't really give any solutions to this
the var that has the file path is a char* and has been converted from a system::string^
it is completely valid when I paste it in windows bar.
Code:

private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) {
        if(textBox1->Text[0] == (char)'\0' || textBox2->Text[0] == (char)'\0'){
                      MessageBox::Show("Please select a valid m3u and path", "Problem",
                                MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
                }
                else{
                        button3->Text = "Working...";
            ReadList();
                }
                }
public: int Form1::ReadList(){
        ifstream pile;
                int count = 0;
                char inputbuff[100] ={'\0'},*tok,*folder;
                String^ poo = textBox1->Text;
                progressBar1->Maximum = File_Quant(poo);
                pile.open(ConvertString(poo),ifstream::in);

public: char* Form1::ConvertString(String^ cnv){
        int length = cnv->Length;
        char *out = new char[length+1];
      for(int i = 0;i < length;i++){
        out[i] = (char) cnv[i];
                out[length] = '\0';
                }
          return out;
                }

it crashes right at the pile.open() function call when I put breakpoints in it says , debug assertion failed
and shows me the fclose.c file location and Expression: (stream != NULL)
I know there are other posts similiar but not exactly like this and they don't offer much in the way of a solution.
Thanks.

Viewing all articles
Browse latest Browse all 3046

Trending Articles