I'm writing a VS C# app using the p4api.net to access a P4 server. The P4V app accesses the depository fine with a given user/password. Using p4api.net API, the code executed the Connect() & Login() methods without exception using server/user/password strings passed in from a form:
rep.Connection.Connect(options);
rep.Connection.Login(password, options);
Below is the actual code:
String conStr = mServerConnection.Text;
String user = mUserText.Text;
String password = mPaswordTxt.Text;
try
{
Server server = new Server(new ServerAddress(conStr));
rep = new Repository(server);
rep.Connection.UserName = user;
Options options = new Options();
Options["Password"] = password;
rep.Connection.Client = new Client();
rep.Connection.Connect(options);
rep.Connection.Login(password, options);
}
catch (Exception ex)
{
rep = null;
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
However during another call to access the P4 "//depot" root directory, the API call _repository.GetDepotDirs() would return "Perforce Password (P4PASSWD) invalid or unset" exception. Please see code below:
public bool Expand()
{
if (String.IsNullOrEmpty(depotPath))
return false;
// if we have the depot path, get a list of the subdirectories from the depot
if (!String.IsNullOrEmpty(depotPath))
{
IList<string> subdirs = _repository.GetDepotDirs(null, String.Format("{0}/*", depotPath));
I read somewhere that I need to set the environmental variable P4TICKETS so I did that in a DOS prompt:
p4 set P4TICKETS=C:\Documents and Settings\my_user_name
but this didn't resolve the problem. I'd appreciate your help. Thanks.