Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
this is my UnRAR a file code,its not working when there is space in the path(egBig Grin | :-D :\UnRAR File\Files).if there is no space(egBig Grin | :-D :\UnRARFile\Files) i can able to unrar.
 
so someone plz help me...
 
string the_Info;
 
            ProcessStartInfo the_StartInfo;
            Process the_Process;
            try
            {
                string path = @"" + fstrpath + "";
                string RarFile_dir = "";
 
                RarFile_dir = @"" + fstrpath + "\\" + fstrRarFileName + "";
 
                // if unRAR files exist delete it
                if (Directory.Exists(RarFile_dir) == true)
                    Directory.Delete(RarFile_dir, true);
 
                the_Info = " X " + path + "\\" + fstrRarFileName + ".rar " + " " + path;
                the_StartInfo = new ProcessStartInfo();
 
                the_StartInfo.FileName = path + "\\winRAR.exe";
                the_StartInfo.Arguments = the_Info;
                the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                the_StartInfo.WorkingDirectory = path;
                the_Process = new Process();
                the_Process.StartInfo = the_StartInfo;
                the_Process.Start();
                the_Process.WaitForExit();
                the_Process.Close();
                RarFile_dir = @"" + path + "";
            }
 
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
Posted 2-Dec-12 20:47pm
Edited 3-Dec-12 1:11am
v3

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

If you're constructing an argument list for an external executable, for instance, all you have to do is quote the path:
 
string path = @"C:\TestFolder\Input\Some File.rar";
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "program.exe";
psi.Arguments = "\"" + path + "\""; // escape the quotes
 
..which will result in this commandline:
 
program.exe "C:\TestFolder\Input\Some File.rar"
  Permalink  
Comments
@AmitGajjar at 3-Dec-12 7:34am
   
Correct 5+
Mendor81 at 3-Dec-12 8:46am
   
Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 390
1 Jochen Arndt 150
2 Richard MacCutchan 135
3 DamithSL 95
4 Garth J Lancaster 90
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,260


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 3 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100