none
while processing file from source to destination using process.StartInfo ,getting an error file not found ?

    Question

  • Hi All,

    while processing file from source path to destination path using process.StartInfo ,getting an error :- The system cannot find the file specified.

    I have pasted source code into code block.plesase look the commented lines as well.

    could you please help to resolve the error.

       StackTrace : at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
       at System.Diagnostics.Process.Start()

     
    
    public string submitFile(string SourceFilePath, string CWID, string SystemName, string destFileName, string fileType)
                {
                        string strresult = "";
                        try
                        {
                            string strDestPath = _configurationManager.AppSettings["Attachmentpath"];
                            if (SystemName.Trim() == "xvalue")
                            {
                                string BatfilePath = _configurationManager.AppSettings["BatFilePath"];
    
    
                                if (File.Exists(SourceFilePath))
                                {
                                    destFileName = destFileName.Replace("\"", "");
                                    string DestinationFilePath = "\"" + strDestPath + "\\" + CWID + "_" + destFileName + "." + fileType + "\"";
                                    System.Diagnostics.Process process = new System.Diagnostics.Process();
    
                                    process.StartInfo.FileName = BatfilePath + "Unzip.bat";
                                    process.StartInfo.UseShellExecute = false;
    
                                    //here maping sourec and destination paths like below :-
    				//SourceFilePath = D:\Data\CWAttachment\test.txt
    				//DestinationFilePath; D:\RetValue\CWAttachment\cW123_test.txt
    
                                    process.StartInfo.Arguments = SourceFilePath + "\t" + DestinationFilePath;
    
    
                                    process.Start();//this place i am getting an error 
                                    process.WaitForExit();
                                    strresult = "Processed";
                                }
                                else
                                {
    
                                    strresult = "FileNotFound";
                                }
    
                            }
                        }
                        catch (Exception ex)
                        {
                         //Log.Error("Error occured while submitFile an CWAttachmentInfo ", ex);
                        }
                        return strresult;
                    }

    Regards,

    Sanath Avula 


    sanath.avula@gmail.com



    • Edited by AvulaSanath Tuesday, April 18, 2017 3:32 PM stack ex adding
    Tuesday, April 18, 2017 1:51 PM

All replies

  • Most likely the error happens due to the "\t" that you are using to separate the two filenames. Probably the target program does not interpret it as a valid separator and instead thinks that it is part of the filename and therefore results in a file that doesn't exist.

    Try changing it into a blank space " " instead of the tab "\t" and see if that works.

    Wednesday, April 19, 2017 5:54 AM
    Moderator
  • thanks for the reply.

    I have tried changing from "\t" to "" blank space ,but no luck .

    still getting same issue.

    Regards,

    Sanyasi Avula


    sanath.avula@gmail.com

    Wednesday, April 19, 2017 11:22 AM