简体   繁体   中英

I get an “Invalid Name” error when I try to use “CopyEx”

Regarding my previous problem that is now fixed, I got another problem with the //code here part :/

foreach (ManagementObject obj in ObjSearcher.Get())
{  
    ManagementBaseObject inputArgs = obj.GetMethodParameters("CopyEx");
    inputArgs["FileName"] = "\\c:\\1stuff";
    inputArgs["Recursive"] = true;
    ManagementBaseObject outParams = obj.InvokeMethod("CopyEx", inputArgs, null);
    uint ret = (uint)(outParams.Properties["ReturnValue"].Value);
}

I keep getting a returnvalue of 9, which is "Invalid Name". I have no idea what got an invalid name nor how to fix it. Both folder exist.

You have a leading backslash in your file name. Try removing it. I'm not aware of any file paths that have the format you're using.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM