3
With Openfiledialog I am opening a file, and I want Load to change the extension. That is, I’ll put that the "openFileDialog1.Filter" would only be for ". txt" and I want it to change to ". cnf". Thank you.
3
With Openfiledialog I am opening a file, and I want Load to change the extension. That is, I’ll put that the "openFileDialog1.Filter" would only be for ". txt" and I want it to change to ". cnf". Thank you.
2
I don’t know why this is, but a simple solution is for you to do it this way:
//aqui vai o caminho que você leu no OpenFileDialog
string caminho = "arquivo.txt";
//e aqui você cria uma variável que irá receber o novo caminho.
string novoCaminho = caminho.Remove(caminho.Length -3, 3) + "cnf";
Basically what the above line does is remove the txt
of the file and add the cnf
;
Only you will have to save the file for it to stay with this extension.
Or you can use a native function of C#
:
string caminhoPath = Path.ChangeExtension(caminho, ".cnf");
See more about Path.Changeextension().
Browser other questions tagged c#
You are not signed in. Login or sign up in order to post.
What is o Load?
– ramaral
Not on Load, on Button @ramaral.
– Don Vito
I can’t figure out what you want.
– ramaral