none
Impossible save openFileDialog1->FileName on text file (StreamWriter::Write) RRS feed

  • Question

  • I'm working around this problem from many days without success...

    I've these functions:

    void INI_FILE_out(void)
    {
        String^ FILE_TEXT_WRITE;

        StreamWriter^ outfile = gcnew StreamWriter(INI_FILE_NAME_p);
        FILE_TEXT_WRITE = User_p +"|"+Psw_p+"|"+TipoStazione_p+"|"+TempoInvio_p+"|"+FileNome_p+"|"+AutoStart_p;
        outfile->Write(FILE_TEXT_WRITE);
        outfile->Close();
    };

    and

    void FileNome_set( String^ value ) { FileNome_p = value;  }
    Why if I do

    FileNome_set(openFileDialog1->FileName);
    I can't save the FileName on text file?

    Thank's all

    Friday, September 27, 2013 9:30 PM

Answers

  • You have to specify the full path of INI file.

    Try this:

    using namespace System::Windows::Forms;
    using namespace System::IO;
    
    . . . .
    
    INI_FILE_NAME_p = Path::Combine( Path::GetDirectoryName( Application::ExecutablePath), "Options.ini");


    Sunday, September 29, 2013 10:04 AM

All replies

  • Have you called openFileDialog1->ShowDialog() before writing FileNome_p to file? Does INI_FILE_NAME_p contain a valid file path? Show some details.

    By the way, you can also use File::WriteAllText(INI_FILE_NAME_p, FILE_TEXT_WRITE).

    Saturday, September 28, 2013 9:45 AM
  • You have to specify the full path of INI file.

    Try this:

    using namespace System::Windows::Forms;
    using namespace System::IO;
    
    . . . .
    
    INI_FILE_NAME_p = Path::Combine( Path::GetDirectoryName( Application::ExecutablePath), "Options.ini");


    Sunday, September 29, 2013 10:04 AM