using (PrintDialog printDialog1 = new PrintDialog())
{
if (printDialog1.ShowDialog() == DialogResult.OK)
{
System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo(saveAs.ToString());
info.Arguments = "\"" + printDialog1.PrinterSettings.PrinterName + "\"";
info.CreateNoWindow = true;
info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
info.UseShellExecute = true;
info.Verb = "PrintTo";
System.Diagnostics.Process.Start(info);
}
}
The above code works fine. I just don't know how to change the code so that I can preview the Word document first.
Okay, so I worked on this last night after getting home and I believe I figured it out. It's NOT perfect but, it does get you moving in the right direction. BTW, I created a simple WinForms app for this, and you will need to edit the code to suit your needs.
The code:
namespace WindowsFormsApplication1
{
using System;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
System.Drawing.Printing.PrintDocument doc = new System.Drawing.Printing.PrintDocument();
PrintPreviewDialog dlg = new PrintPreviewDialog();
dlg.Document = doc;
doc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.PrintPage);
dlg.ShowDialog();
}
private void PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
try
{
string fileName = #"C:\Users\brmoore\Desktop\New Text Document.txt";
StreamReader sr = new StreamReader(fileName);
string thisIsATest = sr.ReadToEnd();
sr.Close();
System.Drawing.Font printFont = new System.Drawing.Font("Arial", 14);
e.Graphics.DrawString(thisIsATest, printFont, Brushes.Black, 100, 100);
}
catch (Exception exc)
{
MessageBox.Show(exc.ToString());
}
}
}
}
Related
Im trying to create a minecraft server wrapper but im having trouble reading the output of the process. I want to read the output in the serverProcess_ErrorDataRecevied event and I know that what there is now doesn't work. But what could I put there instead to read it?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
namespace MC_Server_UI
{
public partial class Form1 : Form
{
ProcessStartInfo startInfo = new ProcessStartInfo("C:\\Program Files (x86)\\Java\\jre7\\bin\\java.exe", "Xmx1024M - jar " + "craftbukkit.jar" + " nogui");
Process serverProcess;
OpenFileDialog ofd;
FolderBrowserDialog fbd;
public Form1()
{
InitializeComponent();
fbd = new FolderBrowserDialog();
fbd.ShowDialog();
startInfo.WorkingDirectory = fbd.SelectedPath;
startInfo.RedirectStandardInput = startInfo.RedirectStandardError = true;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
serverProcess = new Process();
serverProcess.StartInfo = startInfo;
serverProcess.EnableRaisingEvents = true;
serverProcess.ErrorDataReceived += new DataReceivedEventHandler(serverProcess_ErrorDataReceived);
serverProcess.Exited += new EventHandler(serverProcess_Exited);
serverProcess.Start();
}
private void serverProcess_ErrorDataReceived(object sender, EventArgs e)
{
richTextBox1.AppendText(serverProcess.StandardError.ReadToEnd());
}
private void serverProcess_Exited(object sender, EventArgs e)
{
}
}
}
See:
How to spawn a process and capture its STDOUT in .NET?
ProcessStartInfo.RedirectStandardOutput
Code:
serverProcess.StartInfo.RedirectStandardOutput = true;
serverProcess.OutputDataReceived += (sender, args) => Console.WriteLine("received output: {0}", args.Data);
serverProcess.Start();
serverProcess.BeginOutputReadLine();
Or:
serverProcess.StartInfo.RedirectStandardOutput = true;
var output = serverProcess.StandardOutput.ReadToEnd();
See also: ProcessStartInfo.RedirectStandardError
serverProcess.StartInfo.RedirectStandardError = true;
var error = serverProcess.StandardError.ReadToEnd();
I am having multiple problems, there are going to be multiple usernames and passwords in the listbox...
I need the application to wait while and account is in the text boxes, and then when the textboxes are clear then the account next in the listbox can go to the next line..
Here is the code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net.Mail;
using System.Net;
using System.Text.RegularExpressions;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnOpenFile_Click(object sender, EventArgs e)
{
this.lbAccounts.Items.Clear();
OpenFileDialog Open = new OpenFileDialog();
Open.Title = "Select Email List";
Open.Filter = "Text Document|*.txt|All Files|*.*";
try
{
Open.ShowDialog();
StreamReader Import = new StreamReader(Convert.ToString(Open.FileName));
while (Import.Peek() >= 0)
lbAccounts.Items.Add(Convert.ToString(Import.ReadLine()));
}
catch (Exception)
{
}
}
private void SendTestMail()
{
try
{
NetworkCredential loginInfo = new NetworkCredential(txtUser.Text, txtPass.Text);
MailMessage msg = new MailMessage();
msg.From = new MailAddress(txtUser.Text);
msg.To.Add(new MailAddress("example#gmail.com"));
msg.Subject = "Hi, I'm Valid :D";
msg.Body = txtUser.Text + ":" + txtPass.Text;
msg.IsBodyHtml = true;
SmtpClient client = new SmtpClient("smtp.gmail.com");
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = loginInfo;
client.Send(msg);
lbGoodAccounts.Items.Add(txtUser.Text + ":" + txtPass.Text);
txtUser.Clear();
txtPass.Clear();
}
catch (Exception)
{
lbFailAccounts.Items.Add(txtUser.Text + ":" + txtPass.Text);
txtUser.Clear();
txtPass.Clear();
}
}
private void btnCheck_Click(object sender, EventArgs e)
{
SendTestMail();
}
private void btnExport_Click(object sender, EventArgs e)
{
StreamWriter Write;
SaveFileDialog Open = new SaveFileDialog();
try
{
Open.Filter = ("Text Document|*.txt|All Files|*.*");
Open.FileName = ("Good Gmail Accounts");
Open.ShowDialog();
Write = new StreamWriter(Open.FileName);
for (int I = 0; I < lbGoodAccounts.Items.Count; I++)
{
Write.WriteLine(Convert.ToString(lbGoodAccounts.Items[I]));
}
Write.Close();
}
catch (Exception ex)
{
MessageBox.Show(Convert.ToString(ex.Message));
return;
}
}
}
}
If I understood you right this is the code you will need :
void AccountsListBox_Click (object sender, EventArgs args)
{
if (AccountsListBox.SelectedIndex < 0)
return;
if (!string.IsNullOrEmpty(TextBoxName.Text) && !string.IsNullOrEmpty(TextBoxPass.Text))
return; // stop processing if they have some data
// otherwise get acccount:password,
// split it into acc and pass and write them to TextBoxes
string value = AccountsListBox.Items[AccountsListBox.SelectedIndex];
string[] values = value.Split(':');
if (values.Length != 2)
return; // wrong format
var acc = values[0];
var pass = values[1];
TextBoxName.Text = acc;
TextBoxPass.Text = pass;
}
I haven't used WinForms for some time so if you find some errors please correct them :)
See MSDN ListBox documentation for details.
I have the following code so that I can search directories to find files. Now I want to add a way for users to Save the output to a text file?
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
namespace RecursiveSearchCS
{
public class Form1 : System.Windows.Forms.Form
{
internal System.Windows.Forms.Button btnSearch;
internal System.Windows.Forms.TextBox txtFile;
internal System.Windows.Forms.Label lblFile;
internal System.Windows.Forms.Label lblDirectory;
internal System.Windows.Forms.ListBox lstFilesFound;
internal System.Windows.Forms.ComboBox cboDirectory;
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.btnSearch = new System.Windows.Forms.Button();
this.txtFile = new System.Windows.Forms.TextBox();
this.lblFile = new System.Windows.Forms.Label();
this.lblDirectory = new System.Windows.Forms.Label();
this.lstFilesFound = new System.Windows.Forms.ListBox();
this.cboDirectory = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// btnSearch
//
this.btnSearch.Location = new System.Drawing.Point(608, 248);
this.btnSearch.Name = "btnSearch";
this.btnSearch.Size = new System.Drawing.Size(75, 23);
this.btnSearch.TabIndex = 0;
this.btnSearch.Text = "Search";
this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
//
// txtFile
//
this.txtFile.Location = new System.Drawing.Point(8, 40);
this.txtFile.Name = "txtFile";
this.txtFile.Size = new System.Drawing.Size(120, 20);
this.txtFile.TabIndex = 4;
this.txtFile.Text = "*.*";
//
// lblFile
//
this.lblFile.Location = new System.Drawing.Point(8, 16);
this.lblFile.Name = "lblFile";
this.lblFile.Size = new System.Drawing.Size(144, 16);
this.lblFile.TabIndex = 5;
this.lblFile.Text = "Search for files containing:";
//
// lblDirectory
//
this.lblDirectory.Location = new System.Drawing.Point(8, 96);
this.lblDirectory.Name = "lblDirectory";
this.lblDirectory.Size = new System.Drawing.Size(120, 23);
this.lblDirectory.TabIndex = 3;
this.lblDirectory.Text = "Look In:";
//
// lstFilesFound
//
this.lstFilesFound.Location = new System.Drawing.Point(152, 8);
this.lstFilesFound.Name = "lstFilesFound";
this.lstFilesFound.Size = new System.Drawing.Size(528, 225);
this.lstFilesFound.TabIndex = 1;
//
// cboDirectory
//
this.cboDirectory.DropDownWidth = 112;
this.cboDirectory.Location = new System.Drawing.Point(8, 128);
this.cboDirectory.Name = "cboDirectory";
this.cboDirectory.Size = new System.Drawing.Size(120, 21);
this.cboDirectory.TabIndex = 2;
this.cboDirectory.Text = "ComboBox1";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(688, 277);
this.Controls.Add(this.btnSearch);
this.Controls.Add(this.txtFile);
this.Controls.Add(this.lblFile);
this.Controls.Add(this.lblDirectory);
this.Controls.Add(this.lstFilesFound);
this.Controls.Add(this.cboDirectory);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
/// <summary>
/// The main entry point for the application
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void btnSearch_Click(object sender, System.EventArgs e)
{
lstFilesFound.Items.Clear();
txtFile.Enabled = false;
cboDirectory.Enabled = false;
btnSearch.Text = "Searching...";
this.Cursor = Cursors.WaitCursor;
Application.DoEvents();
DirSearch(cboDirectory.Text);
btnSearch.Text = "Search";
this.Cursor = Cursors.Default;
txtFile.Enabled = true;
cboDirectory.Enabled = true;
}
private void Form1_Load(object sender, System.EventArgs e)
{
cboDirectory.Items.Clear();
foreach (string s in Directory.GetLogicalDrives())
{
cboDirectory.Items.Add(s);
}
cboDirectory.Text = "C:\\";
}
void DirSearch(string sDir)
{
try
{
foreach (string d in Directory.GetDirectories(sDir))
{
foreach (string f in Directory.GetFiles(d, txtFile.Text))
{
lstFilesFound.Items.Add(f);
}
DirSearch(d);
}
}
catch (System.Exception excpt)
{
Console.WriteLine(excpt.Message);
}
}
}
}
Here is also a screenshot of the Application Open:
Open Application Image
I am going to add a save button which saves to a specific location when clicked, how would I go about doing this.
If I am understanding it correctly, use a simple I/O operation.
using(StreamWriter writer = new StreamWriter("debug.txt", true))
{
foreach (string item in lstFilesFound.Items)
{
writer.WriteLine(item.ToString());
}
}
Few extra pointers:
In DirSearch, create a variable for Directory.GetDirectories(sDir). Your present code is causing this thing to calculate in every loop. Look for some more similar refactoring code in other areas.
var dirs = Directory.GetDirectories(sDir);
foreach (string d in dirs)
{
var files = Directory.GetFiles(d, txtFile.Text);
foreach (string f in files)
{
lstFilesFound.Items.Add(f);
}
DirSearch(d);
}
Hope it helps.
I'm assuming it's the list of found files you're wanting to save to a text file, how about this on your save event (rough code so not extensively tested)?
using (FileStream fs = new FileStream("c:\\files.txt", FileMode.Create, FileAccess.Write))
{
using (StreamWriter sw = new StreamWriter(fs))
{
foreach (string item in lstFilesFound.Items)
{
sw.WriteLine(item);
}
}
}
I'm not sure what the problem is here. My program can read the "text" and put it in the Title without any problems, but it crashes and doesn't change the size or color before it does so. I tried asking my classmates for help regarding this, but they say all my code looks correct.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace RetrieveCustomizedForm
{
public partial class Form1 : Form
{
const char DELIM = ',';
string recordIn;
string[] fields;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
const string FILENAME = "C:\\Exercise5\\Data.txt";
stuff stuff1 = new stuff();
FileStream inFile = new FileStream(FILENAME, FileMode.Open, FileAccess.Read);
StreamReader reader = new StreamReader(inFile);
recordIn = reader.ReadLine();
reader.Close();
inFile.Close();
while (recordIn != null)
{
fields = recordIn.Split(DELIM);
stuff1.color = fields[0];
stuff1.size = fields[1];
stuff1.text = fields[2];
if (fields[0] == "red")
{
this.BackColor = System.Drawing.Color.Red;
}
if (fields[0] == "blue")
{
this.BackColor = System.Drawing.Color.Blue;
}
if (fields[0] == "yellow")
{
this.BackColor = System.Drawing.Color.Yellow;
}
if (fields[1] == "large")
{
this.Size = new System.Drawing.Size(500, 500);
}
if (fields[1] == "small")
{
this.Size = new System.Drawing.Size(300, 300);
}
this.Text = fields[2];
}
}
class stuff
{
public string color { get; set; }
public string size { get; set; }
public string text { get; set; }
}
}
}
fields : might be empty, end of the file?
Any file open error? trying to open it again while it is already opened in background?
Some more information might be helpful. Like The others have said, what are the values of fields[0]-[2]? What errors are you receiving? It looks to me like one error you will receive is that your index is outside the bounds of the fields array...Give us some more info and we can better help you.
try it this way
using (FileStream infile = new FileStream(FILENAME, FileMode.Open, FileAccess.Read))
{
using (StreamReader reader = new StreamReader(infile))
{
string recordIn = reader.ReadLine();
while (recordIn != null)
{
fields = recordIn.Split(DELIM);
stuff1.color = fields[0];
stuff1.size = fields[1];
stuff1.text = fields[2];
if (fields[0] == "red")
{
this.BackColor = System.Drawing.Color.Red;
}
if (fields[0] == "blue")
{
this.BackColor = System.Drawing.Color.Blue;
}
if (fields[0] == "yellow")
{
this.BackColor = System.Drawing.Color.Yellow;
}
if (fields[1] == "large")
{
this.Size = new System.Drawing.Size(500, 500);
}
if (fields[1] == "small")
{
this.Size = new System.Drawing.Size(300, 300);
}
this.Text = fields[2];
}
}
}
The error is on the line:
for (int x = 0; x < myList.Count(); x++)
The x++is painted with green.
Im using backgroundoworker and I used this code same code in another form before without a backgroundworker and it worked good. Now in the other form im using a click button event to show() this form and I want to use a progressBar1 to show the progress of the backgroundowrker work.
I used now try and catch inside this for loop and it went to the catch point and showed me the error. The full exception message is:
at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(String filename, ImageFormat format)
at mws.Animation_Radar_Preview.backGroundWorker1_DoWork(Object sender, DoWorkEventArgs e) in D:\C-Sharp\Download File\Downloading-File-Project-Version-012\Downloading File\Animation_Radar_Preview.cs:line 163
gifImages isnt null.
This is the full code of this form:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using DannyGeneral;
using unfreez_wrapper;
namespace mws
{
public partial class Animation_Radar_Preview : Form
{
int mtpStart;
int mtpEnd;
Picturebox1_Fullscreen pb1;
string radar_images_download_directory;
string tempRadarPngToGifDirectory;
int numberOfFiles;
UnFreezWrapper unfreez;
string path_exe;
List<string> myList;
string previewDirectory;
int animatedGifSpeed;
bool loop;
string nameOfStartFile;
string nameOfEndFile;
string previewFileName;
BackgroundWorker backGroundWorker1;
Image img;
private MemoryStream _memSt = null;
public Animation_Radar_Preview()
{
InitializeComponent();
mtpStart = Picturebox1_Fullscreen.mtp1Start;
mtpEnd = Picturebox1_Fullscreen.mtp1End;
animatedGifSpeed = Picturebox1_Fullscreen.animatedSpeed;
loop = Picturebox1_Fullscreen.looping;
pb1 = new Picturebox1_Fullscreen();
radar_images_download_directory = Options_DB.Get_Radar_Images_Download_Directory();
path_exe = Path.GetDirectoryName(Application.LocalUserAppDataPath);
tempRadarPngToGifDirectory = path_exe + "\\" + "tempRadarPngToGifDirectory";
if (Directory.Exists(tempRadarPngToGifDirectory))
{
}
else
{
Directory.CreateDirectory(tempRadarPngToGifDirectory);
}
previewDirectory = path_exe + "\\" + "previewDirectory";
if (Directory.Exists(previewDirectory))
{
}
else
{
Directory.CreateDirectory(previewDirectory);
}
previewFileName = previewDirectory + "\\" + "preview.gif";
loop = false;
animatedGifSpeed = 0;
unfreez = new UnFreezWrapper();
backGroundWorker1 = new BackgroundWorker();
backGroundWorker1.WorkerSupportsCancellation = true;
this.backGroundWorker1.WorkerReportsProgress = true;
backGroundWorker1.ProgressChanged += new ProgressChangedEventHandler(backGroundWorker1_ProgressChanged);
backGroundWorker1.DoWork += new DoWorkEventHandler(backGroundWorker1_DoWork);
backGroundWorker1.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backGroundWorker1_RunWorkerCompleted);
backGroundWorker1.RunWorkerAsync();
progressBar1.Value = 0;
}
private void button2_Click(object sender, EventArgs e)
{
DialogResult result1;
result1 = new DialogResult();
SaveFileDialog sd = new SaveFileDialog();
sd.Title = "Select a folder to save the animated gif to";
sd.InitialDirectory = "c:\\";
sd.FileName = null;
sd.Filter = "Gif File|*.gif;*.jpg|Gif|*.gif";
sd.FilterIndex = 1;
sd.RestoreDirectory = true;
result1 = sd.ShowDialog();
string file1 = sd.FileName;
if (result1 == DialogResult.OK)
{
File.Move(previewFileName, file1);
}
}
public void pictureBoxImage(string pbImage)
{
Image img2 = null;
try
{
using (img = Image.FromFile(pbImage))
{
//get the old image thats loaded from the _memSt memorystream
//and dispose it
Image i = this.pictureBox1.Image;
this.pictureBox1.Image = null;
if (i != null)
i.Dispose();
//grab the old stream
MemoryStream m = _memSt;
//save the new image to this stream
_memSt = new MemoryStream();
img.Save(_memSt, System.Drawing.Imaging.ImageFormat.Gif);
if (m != null)
m.Dispose();
//create our image to display
img2 = Image.FromStream(_memSt);
}
if (img2 != null)
pictureBox1.Image = img2;
label2.Text = numberOfFiles.ToString();
label6.Text = nameOfStartFile.ToString();
label4.Text = nameOfEndFile.ToString();
//File.Delete(pbImage);
}
catch(Exception err)
{
Logger.Write("Animation Error >>> " + err);
}
}
private void backGroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
progressBar1.Value = e.ProgressPercentage;
}
private void backGroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
List<string> myGifList;
Image gifImages = null;
//button1.Enabled = false;
Animation_Radar_Preview ap = new Animation_Radar_Preview();
//ap.FormClosing += new FormClosingEventHandler(ap_FormClosing);
FileInfo[] fi;
DirectoryInfo dir1 = new DirectoryInfo(radar_images_download_directory);
fi = dir1.GetFiles("*.png");
myList = new List<string>();
myGifList = new List<string>();
for (int i = mtpStart; i < mtpEnd; i++)
{
myList.Add(fi[i].FullName);
}
for (int x = 0; x < myList.Count(); x++)
{
try
{
gifImages = Image.FromFile(myList[x]);
gifImages.Save(tempRadarPngToGifDirectory + "\\" + x.ToString("D6") + ".Gif", System.Drawing.Imaging.ImageFormat.Gif);
}
catch (Exception ex)
{
MessageBox.Show(x.ToString() + "\r\n" + (gifImages == null).ToString() + "\r\n" + ex.Message);
}
}
myGifList = new List<string>();
dir1 = new DirectoryInfo(tempRadarPngToGifDirectory);
fi = dir1.GetFiles("*.gif");
nameOfStartFile = fi[0].Name;
for (int i = 0; i < fi.Length; i++)
{
myGifList.Add(fi[i].FullName);
//backGroundWorker1.ReportProgress(i);
nameOfEndFile = fi[i].Name.Length.ToString();
}
numberOfFiles = myGifList.Count();
unfreez.MakeGIF(myGifList, previewFileName, animatedGifSpeed, loop);
/*this.Invoke((MethodInvoker)delegate
{
pictureBoxImage(previewFileName);
});*/
}
private void backGroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
pictureBoxImage(previewFileName);
}
}
}
I'm not entirely sure what is going wrong, especially as you say this same code worked previously — but it is not clear whether it worked with the same set of images.
Anyhow, the documentation for the Save method says that an ExternalException will be thrown in one of two situations:
Image was saved with the wrong format.
Image is saved to the file it was created from.
It cannot be that you are saving over the file because you are changing its extension, so it must be the wrong format. What this actually means is not clear. Perhaps one of the source images is using capabilities of the PNG format that cannot be converted to GIF, e.g. alpha channel transparency.
If I may take a moment to make some other suggestions too:
if (Directory.Exists(tempRadarPngToGifDirectory))
{
}
else
{
Directory.CreateDirectory(tempRadarPngToGifDirectory);
}
The empty 'success' case is not required if you invert the logic:
if (!Directory.Exists(tempRadarPngToGifDirectory)
{
Directory.CreateDirectory(tempRadarPngToGifDirectory);
}
Code that manipulates file paths such as the following:
tempRadarPngToGifDirectory = path_exe + "\\" + "tempRadarPngToGifDirectory";
You should consider using the Path class as this will handle the edge cases better and make more portable code:
tempRadarPngToGifDirectory = Path.Combine(path_exe, "tempRadarPngToGifDirectory");