当我运行程序时,显示“系统找不到指定的路径". [英] when i am running the program its showing"the system cannt find the path specified"

查看:95
本文介绍了当我运行程序时,显示“系统找不到指定的路径".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
			string b =System.Configuration.ConfigurationSettings.AppSettings["OracleConnString"];
			string strSQLLdrPath = System.Configuration.ConfigurationSettings.AppSettings["SQLLDRPath"];
			string strSQLLdrUserId = System.Configuration.ConfigurationSettings.AppSettings["SQLLDRUserId"];
			string strCntrlFilePath = System.Configuration.ConfigurationSettings.AppSettings["CntrlFilePath"];
			string strDataFilePath = System.Configuration.ConfigurationSettings.AppSettings["DataFilePath"];
			string strLogFilePath = System.Configuration.ConfigurationSettings.AppSettings["LogFilePath"];
			string strBadFilePath = System.Configuration.ConfigurationSettings.AppSettings["BadFilePath"];
			try
			{
		
				log.Info("Invoking SQL*Loader to load file: " + strDataFilePath);
				Process p= new Process();
				
				// Start User Name Changes dt-10th Sep 2007
				//				if(strUserId.IndexOf(" ") >= 0)
				//				{
				//					strUserId = strUserId.Replace(" ","");
				//				}
				// End User Name Changes dt-10th Sep 2007
				strLogFilePath = strLogFilePath + "data_"+".log";
				strBadFilePath = strBadFilePath + "data_"+ ".bad";
				p.StartInfo.Arguments=@strSQLLdrUserId + " control= "+ strCntrlFilePath+ " data= "+ strDataFilePath + " log= " + strLogFilePath +" bad= "+ strBadFilePath + " rows=5000 errors=15000 skip=1 ";
				p.StartInfo.FileName = strSQLLdrPath ;
				p.StartInfo.WindowStyle =ProcessWindowStyle.Hidden;
				p.Start();
				p.WaitForExit();
				log.Info("SQL*Loader work completed.");
			}
			catch(Exception ex)
			{
				log.Error("Problems with SQLLoader" ,ex);
			}
		}

推荐答案

在将路径传递到文件名之前添加以下行:

Add this line before passing path to file name:

using System.IO;



要检查路径是否存在:



To Check if path exists:

if(!Directory.Exists(path))
            {
//throw exception here or show message box like this:
MessageBox.Show(path);
            }
else
{
//do something here.
}



要检查文件是否存在:



To check if file exists:

if(File.Exists(filepath)
{
//throw exception here or show message box like this:
MessageBox.Show(filepath)
}
else
{
//do something here.
}


只需逐行调试,看看哪里出现此错误
Just debug line by line and see where you are getting this error


这篇关于当我运行程序时,显示“系统找不到指定的路径".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆