1
string f = "C:\Test@1234.txt"
cmd = new P4Command(p4, "add", true, "-c", changelist.Id.ToString(), f);

When my file name contains "@" this character , it log error exception :

add file get this Can't add filenames with wildcards [@#%*] in them

How do I fix that , I using p4api.net.

Samwise
  • 68,105
  • 3
  • 30
  • 44
TimChang
  • 2,249
  • 13
  • 25
  • CMD - *Command Prompt (executable name cmd.exe) is the Microsoft supplied command line interpreter on OS/2, Windows CE, and all Microsoft Windows operating systems. Use this tag for questions regarding programming scripts or on commands available to run from the Command Prompt. Add tags for which version of Windows, and tags describing the task or issue. * What is your CMD question? –  Dec 27 '19 at 08:40

1 Answers1

2

From the command line you can pass the -f flag to force files with wildcards to be added:

C:\Perforce\test\chars>p4 add -n foo@bar
The file named 'foo@bar' contains wildcards [@#%*].
Can't add filenames with wildcards [@#%*] in them.
Use -f option to force add.

C:\Perforce\test\chars>p4 add -n -f foo@bar
//stream/main/chars/foo%40bar#1 - opened for add

It looks like P4Command lets you just pass a server command (and its arguments) to the constructor, so you should be able to do:

new P4Command(p4, "add", true, "-c", changelist.Id.ToString(), "-f", f);
Samwise
  • 68,105
  • 3
  • 30
  • 44
  • thanks man it's worked. And I fix 'edit' and 'reopen' command also. like this `f = filePath.Replace("@", "%40");cmd = new P4Command(p4, "edit", true, command, changelist.Id.ToString(), f);` – TimChang Dec 27 '19 at 09:08