Jalkhov
New member
- Joined
- Mar 24, 2021
- Messages
- 3
- Programming Experience
- 3-5
Hi, I'm trying to compress a folder with RAR through a button, when I press it for the first time, everything runs correctly, but when I try to do it a second time I get the title error, I think the problem is with the process but I don't know exactly how to fix it.
This is my code
I am thinking that the problem is that when I perform the action a first time, the Rar.exe file starts to be used, and when I try to perform the action a second time the file is still in use and is not available or something like that, but it is strange, because I check the task manager and the process is finished a second time, it should be clarified that I can do that action as many times as I want when I finish running the program and reopen it, but not when I try to do it more than once in a "session". Another thing, the error gives me specifically in the line of p.Start();
This is my code
C#:
string directory = Directory.GetCurrentDirectory();
string RarExe = Path.Combine(directory, "Rar.exe");
Directory.SetCurrentDirectory(projectdirval.Text); // This is for work inside the project directory
Process p= new Process();
p.StartInfo.FileName = RarExe;
p.StartInfo.Arguments = String.Format("a -r {0}", "c:\\MyFile.rar");
p.Start();
p.WaitForExit();
I am thinking that the problem is that when I perform the action a first time, the Rar.exe file starts to be used, and when I try to perform the action a second time the file is still in use and is not available or something like that, but it is strange, because I check the task manager and the process is finished a second time, it should be clarified that I can do that action as many times as I want when I finish running the program and reopen it, but not when I try to do it more than once in a "session". Another thing, the error gives me specifically in the line of p.Start();
Last edited by a moderator: