From my previous question here I was writing a program that executes A number of files through CMD.
Here is my Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;
using System.Diagnostics;
namespace Convert
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
private void BtnSelect_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog Open = new OpenFileDialog();
Open.Filter = "RIFF/RIFX (*.Wav)|*.wav";
Open.CheckFileExists = true;
Open.Multiselect = true;
Open.ShowDialog();
LstFile.Items.Clear();
foreach (string file in Open.FileNames)
{
LstFile.Items.Add(file);
}
}
private void button1_Click(object sender, RoutedEventArgs e)
{
LstFile.Items.Clear();
}
private void BtnConvert_Click(object sender, RoutedEventArgs e)
{ Process p = new Process();
p.StartInfo.FileName = "cmd";
p.StartInfo.UseShellExecute = false;
foreach (string fn in LstFile.Items)
{
string fil = "\"";
string gn = fil + fn + fil;
p.Start();
p.StartInfo.Arguments = gn;
}
}
}
}
i used
string fil = "\"";
string gn = fil + fn + fil;
to provide quotation marks around the full file name in case the filename has spaces.
My problem is that my program Opens CMD Put does not pass any arguments in it.I checked if the filnames(list) are working and they are fine.Looking at the examples this is the way to do it,but obviously something is wrong
set
Before you start the process, and I’d suggest making a new process class for each process that you start.
example:
If you’re trying to call cmd commands, make your arguements
"/c \"what i would type into the command Line\""This is an example of what I did quick. It opens a text document in notepad