UnRAR文件存在于目录中 [英] UnRAR files present in a directory

查看:331
本文介绍了UnRAR文件存在于目录中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的UnRAR文件代码,当路径中有空格时它不起作用(例如:D:\ UNRAR File \Files)。如果没有空格(例如:D:\ UNRARFile \文件)我可以unrar。



所以有人请帮我...



this is my UnRAR a file code,its not working when there is space in the path(eg:D:\UnRAR File\Files).if there is no space(eg: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);
            }

推荐答案

例如,如果您正在构建外部可执行文件的参数列表,那么您只需要引用路径:



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"


这篇关于UnRAR文件存在于目录中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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