[C#] create & write a file in the app. sub folder
I am currently trying to create & write to a .bat file.
I have done all that fine
Code:
ct.WriteLine(Application.StartupPath + "mrs.exe d " + (comboBox1.SelectedItem.ToString()));
It compiles perfect, everything does what it supposed to do.
But, What I want it to do is create & write a file in my apps sub-folder called "files"
This might give you some info,
Code:
ct.WriteLine(Application.StartupPath + \\files "mrs.exe d " + (comboBox1.SelectedItem.ToString()));
How would I write to that .bat file? Without the c:\\Documents & Setting\\etc..
Re: [C#] create & write a file in the app. sub folder
Uhh..
ct.WriteLine(Application.StartupPath + "files\\mrs.exe d " + (comboBox1.SelectedItem.ToString())); ?
Did I miss something?
Re: [C#] create & write a file in the app. sub folder
I have tried that, it also writes that part to that .bat file.
the only thing that can be in the .bat file is
mrs.exe d whatever.mrs
edit: Sorry, that is my old code, it looks like this:
Code:
ct.WriteLine ("mrs.exe d " + (comboBox1.SelectedItem.ToString()));
Re: [C#] create & write a file in the app. sub folder
Oh, right, your bat file will be in the \files -folder, not the mrs.exe...
I'm not familiar with C# classes, but obviously the path will go into the operation that opens the .bat file, not the writeline.
Re: [C#] create & write a file in the app. sub folder
Quote:
Originally Posted by
shortymant
I have tried that, it also writes that part to that .bat file.
the only thing that can be in the .bat file is
mrs.exe d whatever.mrs
edit: Sorry, that is my old code, it looks like this:
Code:
ct.WriteLine ("mrs.exe d " + (comboBox1.SelectedItem.ToString()));
PHP Code:
ct.WriteLine (Application.StartupPath + @"\files\mrs.exe d " + (comboBox1.SelectedItem.ToString()))
Rather Simple...
You had \\files which is a commend and it was outside the quote =]
Re: [C#] create & write a file in the app. sub folder
My first code was misleading. I forgot to take that part out. It works like this:
Code:
ct.WriteLine ("mrs.exe d " + (comboBox1.SelectedItem.ToString()));
But, if I add the Application.StartupPath, even without " " it writes the whole path.
It included the whole path in the .bat file, which would make the .bat file use less.
Re: [C#] create & write a file in the app. sub folder
Ok what you can do is add to the combo box a list without the extensions (.mrs) and then on the button add this code:
PHP Code:
Using System.IO;
File.WriteAllText(Application.StartupPath + "\\Files\\" + comboBox1.SelectedItem + ".bat", "mrs.exe d " + comboBox1.SelectedItem + ".mrs");
Re: [C#] create & write a file in the app. sub folder
Ty very much Xzeenon ^^.
It worked, but it's having problems de/compiling, and deleting the .bat file after use.
I'll just leave it as it was. =/
Re: [C#] create & write a file in the app. sub folder
You don't need to make a .bat and all that. There's a command which you can use to start mrs.exe with arguments.
Re: [C#] create & write a file in the app. sub folder
Quote:
Originally Posted by
Mr.Lucifer
You don't need to make a .bat and all that. There's a command which you can use to start mrs.exe with arguments.
He's right.
It's what I did for my decompiler.
Process myproc = new Process();
myproc.StartInfo.FileName= = "mrs.exe";
myproc.StartInfo.Arguments = "d " + comboBox1.SelectedItem + ".mrs";