C # path Space --- ProcessStartInfo parameter problem,

Source: Internet
Author: User

C # path Space --- ProcessStartInfo parameter problem,

To transfer a program from one program to another, you must use:
ProcessStartInfo startInfo = new ProcessStartInfo ("\ Program Files \ IE \ IE.exe", s );
Process. Start (startInfo );
However, Process. Start (string) is not supported for wm.

Here s refers:
String fullname = treeView1.SelectedNode. FullPath;
// String s = "\" "+ @ fullName + "\"";
String s = @ fullName;
In the beginning, I am still stupid. @ \ "+ fuluuname is incorrectly used, and @ directly follows the path name. Automatically recognized by the system.

After passing the parameter, how can this parameter be used:
In the started Program
[MTAThread]
Static void Main (string [] args)
{

If (string. IsNullOrEmpty (string. Join ("", args )))
{Application. Run (new Form1 ());}
Else
{

Application. Run (new Form1 (string. Join ("", args )));
}
}
Here, you must note that "" is based on a space, and args will automatically divide the space into arrays, as shown in figure
D: \ My Documents ENTs, which is divided into arg [0] = D: \ My arg [1] = Documents
I started to think that I had a problem with the rewrite of ie because of this problem. In addition, it is not very convenient to adjust wm and it is really depressing. The space character is not escaped. Only the null character has the Escape Character \ 0. Sometimes people on the Internet who name the title as the space escape character are not explicitly marked, and are in disorder.
I also found one piece in the network.
Http://www.cnblogs.com/tuyile006/archive/2006/05/09/395193.html
Well written but not debugged as follows:
In the past few days, a communication program needs to be run to start a process.
Sometimes the results can be called normally, and sometimes problems occur.
The error code is as follows:

Process p = Process. Start (t_path.Text.ToString (), t_file.Text.ToString ());
The first parameter of Process. start () is the name of the running program, followed by the program parameter.

If the two paths do not contain spaces, they can run normally,
If a path Program such as "D: \ Program Files \" or "G: \ Documents and Settings" is included, a problem occurs.
The reason is that in the running line, if the program only receives one parameter, a space in the parameter is equivalent to a carriage return.
That is to say, if you run the input: c: \ aa.exe d: \ Program Files \ tt.txt
Actually, it runs c: \ aa.exe d: \ Program.
This will definitely cause an error.

The correct statement should be:
Process p = Process. Start ("\" "+ t_path.Text.ToString () +" \ "", "\" "+ t_file.Text.ToString () + "\"");

This method is absolutely safe.

If (args. Length <= 0)
{Application. Run (new Form1 ());}
Else
{

Application. Run (new Form1 (args [0]);
}
After referencing another program from one program, sometimes the second program is started separately.
Deployment and/or registration failed. Error: 0x8973190e. An error occurred while writing the file "% CSIDL_PROGRAM_FILES % \ *. exe. Error 0x80070020: Another program is using this file and the process cannot be accessed
At this time
In fact, the path of this stuff is under \ *. exe under my document, and no program is using this file.
Select File on mobile-Clear the saved state, and then exit mobile.
The file on the simulation is of course my English version, and then select a similar option of clear in it.
You can also refer
Http://www.wmisv.com.cn/bbs/dispbbs.asp? Boolean ID = 2 & ID = 5065


In the C language, what is the symbol (->) and how to use it?

This is a symbol in the struct pointer. Write a program to explain it, for example:
# Include <stdio. h>
Struct STU // define a struct
{
Int num;
} Stu;
Int main ()
{
Struct STU * p; // defines a struct pointer.
P = stu; // p points to the struct variable stu.
Stu. num = 100; // attaches an initial value to the struct member num.
Printf ("% d", p-> num); // output the num value in stu
Return;
}
As you can see, the-> method is to reference the variable in the struct !!
Format: p-> struct member (such as p-> num)
The function is equivalent to stu. num or (* p). num.
I don't know. You don't understand, and don't understand call me. O (∩ _ ∩) O ~
Hope to adopt it.

In the C language, what is the symbol (->) and how to use it?

This is a symbol in the struct pointer. Write a program to explain it, for example:
# Include <stdio. h>
Struct STU // define a struct
{
Int num;
} Stu;
Int main ()
{
Struct STU * p; // defines a struct pointer.
P = stu; // p points to the struct variable stu.
Stu. num = 100; // attaches an initial value to the struct member num.
Printf ("% d", p-> num); // output the num value in stu
Return;
}
As you can see, the-> method is to reference the variable in the struct !!
Format: p-> struct member (such as p-> num)
The function is equivalent to stu. num or (* p). num.
I don't know. You don't understand, and don't understand call me. O (∩ _ ∩) O ~
Hope to adopt it.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.