Save file with saveFileDialog1 in VB 2015

0

I am developing a desktop application that after some processes I need to record two files. To do this in a "SAVE" button I linked it to a SaveFileDialog where the operator enters the final name of the file.
What I need to do is save the file as the operator puts it, and at the same time I need to record the same file with some modifications in both the content and the file name.
That is, if the operator gives the file the name:
"exit202.cut" (the files have that extension) I also need to record the "exit202-test.cut".
The first file records it perfect, but I'm having a problem generating the second file. That's what I'm doing for the first file:

Dim Archivo As StreamWriter = File.CreateText(saveFileDialog1.FileName)
        'Agregagamos El Texto
        If IsNothing(txtVCUT.Text) = False Then
            Archivo.WriteLine(txtVCUT.Text)

            'Borra todos los búferes del sistema de escritura actual 
            Archivo.Flush()
            'Cierra el actual objeto StreamWriter 
            Archivo.Close()
        End If

Then I made for the second file:

Dim ArchivoTest As StreamWriter = File.CreateText(System.IO.Path.GetFileNameWithoutExtension(saveFileDialog1.FileName) & "-test.cut")

        If IsNothing(txtTEST.Text) = False Then
            ArchivoTest.WriteLine(txtTEST.Text)

            'Borra todos los búferes del sistema de escritura actual 
            ArchivoTest.Flush()
            'Cierra el actual objeto StreamWriter 
            ArchivoTest.Close()
        End If

I get the name of the file that was put in the SaveFileDialog and I "arm" the last part of the file adding "-test.cut"
Well ... the result is that it does not record anything at all ... does anyone have experience with this control, so that it can give me a hand?

    
asked by MNibor 17.10.2017 в 16:10
source

1 answer

1

The file with the modified name is saving it in the folder where you are running the program, since you are not specifying the route. System.IO.Path.GetFileNameWithoutExtension() only brings the name of the file, not its route too.

    
answered by 17.10.2017 / 16:34
source