Balaji Venkatachalam Balaji Venkatachalam - 1 year ago 195
C# Question

Coded UI - Keyboard.sendkeys - Sending path of a file containing special characters

I'm trying to send the path of a file (dynamically) containing special characters in it using keyboard.sendkeys in codedui:

string filepath="I:\^abc\abc\filename.csv";

For some reason, ^abc in the filepath is treated as special character and sendkeys is not sending it.

Is there a workaround for this or an efficient way of doing this? I'm basically selecting a windows file i.e., through a windows prompt.

Answer Source

According to the docs, ^ is a modifier character. Adding it before a character sends that as a control key combo. For example, "^a" would send CTRL+A.

Try wrapping the "^" in braces, like this, to escape it:

string filepath="I:\{^}abc\abc\filename.csv";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download