if (!Directory.Exists(path)) //判断是否存在某个文件夹 {//不存在 Directory.CreateDirectory(path); //创建文件夹 } if (!File.Exists(filePath)) //判断是否存在某个文件 { FileStream fs = File.Create(filePath);//创建文件 File.Delete(realInvImgPath);//删除文件 fs.Close(); }
System.Diagnostics.Process.Start(Application.StartupPath + "\\XX.exe").WaitForExit();
System.Diagnostics.Process.Start(Application.StartupPath +"\\XX.exe", "参数1 参数2");
Process p = new Process(); p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.FileName = Application.StartupPath + "\\XX.exe"; p.StartInfo.CreateNoWindow = true; p.StartInfo.Arguments = "参数一 参数二 参数三";//传入参数,没有传空,空格分割 p.Start(); p.WaitForExit(); string output = p.StandardOutput.ReadToEnd(); int exitCode = p.ExitCode; MessageBox.Show(exitCode.ToString());
static void Main(string[] args) { if (args.Length > 0) { string canshu1 = args[0]; string canshu2 = args[1]; MessageBox.Show(canshu1); MessageBox.Show(canshu2); } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); }
string logPath = AppDomain.CurrentDomain.BaseDirectory + "\\XX.txt";//文件夹所在地址
System.IO.File.AppendText //附加文本到最后 System.IO.File.ReadAllText(Path, System.Text.Encoding.Default) //读取所有文本内容
string filePath = AppDomain.CurrentDomain.BaseDirectory + "data"; string[] strFileName = Directory.GetFiles(filePath, "*.txt"); foreach (var item in strFileName) { File.Delete(item); }
Console.ReadLine();
bool a = String.IsNullOrEmpty("111"); //判断是否为空
if (!a) { string b = Convert.ToDecimal(123).ToString("0.00");//保留两位小数 }
form1.StartPosition = FormStartPosition.CenterScreen;
(string)dgvgongxg.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;//获取当前选中单元格的行号和列号的值 dataGridView1.Row[i].Cells[j].Value;//获得某个(指定的)单元格的值: dataGridView1.SelectedRows.Count;//获得选中的总行数: dataGridView1.CurrentRow.Index;//获得当前选中行的索引 dataGridView1.CurrentCell.Value;//获得当前选中单元格的值: dataGridView1.SelectedCells(0).Value.ToString 取当前选择单元内容 string[] str = new string[dataGridView.Rows.Count]; for(int i;i<dataGridView1.Rows.Count;i++) { if(dataGridView1.Rows[i].Selected == true) { str[i] = dataGridView1.Rows[i].Cells[1].Value.ToString();//取选中行的数据 } }
原文:https://www.cnblogs.com/arling/p/11863677.html