replace in type not working

Pajito

New member
Joined
May 11, 2020
Messages
1
Programming Experience
1-3
Hi everybody,

I am totally new in c#, I installed NReco Nuget Package and I am trying to experiment with it. All I want is to replace a part of a var with the text of a combobox but anything I tried seems not to be working,bellow you can find my code.
I hope it is understandable.

thanks you in advance
Pajito

C#:
private void btnConvert_Click(object sender, EventArgs e)
{
    OpenFileDialog ofd = new OpenFileDialog();

    if (ofd.ShowDialog() == DialogResult.OK)
    {
        var convert = new NReco.VideoConverter.FFMpegConverter();
        string a = "NReco.VideoConverter.Format.mp4";

        a = a.Replace("NReco.VideoConverter.Format.mp4", "NReco.VideoConverter.Format" + comboBox1.Text);

        convert.ConvertMedia(ofd.FileName, @textBoxDest.Text + ((char)92) + textBoxName.Text + comboBox1.Text, NReco.VideoConverter.Format.mp4);

        MessageBox.Show("Converted MPLIET");
    }
}
 
Last edited by a moderator:
This is rather cumbersome but it is probably doing exactly what you expect:
C#:
a = a.Replace("NReco.VideoConverter.Format.mp4", "NReco.VideoConverter.Format" + comboBox1.Text);
Did you actually bother to look and see what a contained after that? The real problem is that you don't actually use the a variable after that. It's hard for us to tell you exactly what you need to do without any experience with that package but if you expect to use the result of the replacement then you might try using it.

That said, I'm not sure that you should be using it. It's hard to tell what those arguments to ConvertMedia are supposed to be as you've provided no explanation.
 
anything I tried seems not to be working
You have to be more descriptive than jsut "seems not to be working". Tell us what result you were expecting, and what actual result you are getting.

In your code above, what is the value of your a variable before line 10? What is the value after executing line 10? What value were you expecting to see?

You don't seem to use a anywhere afterwards. How do you know that is causing an issue? Or is the intent to pass a as the last parameter to ConvertMedia on line 12? If so, the simplest thing to do is to have assign the actual enum values into the combo box item tag values and just pull them out instead of trying to compose a type name and then getting an enum out of it. If so, the simplest thing to do is to add an object that has the display string and the actual enum value to the combo box and set the DisplayMember to pull the display string from the object. See the ComboBoxColllection.Add() documentation.
 
Last edited:
Back
Top Bottom