When I tested, I found that these two lines seemed to be enough:
string deleteTarget = "testCredential";
Process.Start("cmdkey.exe", "/delete:"+deleteTarget);
By the way, if you need to view the list of credentials, you can refer to the following code:
string cSplitString = "target=";
var targets = new List<string>();
var proc = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "cmdkey.exe",
Arguments = "/list",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};
proc.Start();
while (!proc.StandardOutput.EndOfStream)
{
string line = proc.StandardOutput.ReadLine();
if (line.Contains(cSplitString))
targets.Add(line.Substring(line.IndexOf(cSplitString) + cSplitString.Length));
}
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.