C# file not saving on correct folder -
i need save txt file on correct create folder. saving on c:\nova pasta need save on "c:\nova pasta\"+valor.retorna_nome+combobox1.text whats wrong ?
private void btn_savefile_click(object sender, eventargs e) { objsql.search_rgp_cadastroprint(convert.toint32(combobox1.text), str_list); objsql.searchprint(convert.toint32(combobox1.text)); string path = @"c:\nova pasta\"+valor.retorna_nome+combobox1.text; if (!directory.exists(path)) { directory.createdirectory(path); } streamwriter file = new system.io.streamwriter(path + ".txt"); file.writeline("---------------------------------------------------------------------------------------------------------"); file.writeline("nome: " + valor.retorna_nome); file.writeline("rgp: " + combobox1.text); file.writeline("endereço: " + valor.retorna_endereco); file.writeline("telefone: " + valor.retorna_telefone + " celular: " + valor.retorna_celular + "\r\n"); str_list.foreach(file.writeline); file.close(); }
say valor.retorna_nome
"hello", , combobox1.text
"world". code following:
string path = @"c:\nova pasta\"+valor.retorna_nome+combobox1.text; // -> path = "c:\nova pasta\helloworld" if (!directory.exists(path)) { directory.createdirectory(path); // -> created directory "c:\nova pasta\helloworld" } streamwriter file = new system.io.streamwriter(path + ".txt"); // -> writes file "c:\nova pasta\helloworld.txt"
so it's doing told to. directory called? , filename?
Comments
Post a Comment