I am using copy file and the Drive I am copying to has C\users\my firstname.my last name. I am trying to make it a wildcard . when I use any wild card its says illegal charcaters. Help please
@mma - Hello, try to use %USERPROFILE%
instead. It represents the user folder. Hope this helps!
If that doesnβt work, you can try:
strUserFolder= Environment.ExpandEnvironmentVariables("%HOMEDRIVE%%HOMEPATH%");
Or
strUserFolder = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)
Okay I will use copy file c/user/%USERPROFILE%/(D Drive ? could I use this also for Move file ?
I dont want to hard copy my name because the end user can be anyone in the future.
@mma - WriteLine any of the suggested codes and see which one you need:
Environment.ExpandEnvironmentVariables("%USERPROFILE%")
or
Environment.ExpandEnvironmentVariables("%HOMEDRIVE%%HOMEPATH%")
or
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)
I am trying to move a file from one drive to another using Move File , . when I use the Move File it only works when I have my name hard copy example C\users\my firstname.my last name. I dont want to have my name save in the code . I tried replacing it with wild card but its says illegal characters
@mma - To test, try to use the Write Line or Message Box activity with the above suggested codes to see if it gives you the string/path you need. Then you can use it as the parameter for the Move File activity.
Environment.ExpandEnvironmentVariables(β%USERPROFILE%β) works in message box. How will use it in a parameter in move file ?
AM i supposed to replace the Environment.ExpandEnvironmentVariables(β%USERPROFILE%β) with the users name ?
@mma - Using that code will automatically replace the username depending on what machine the automation runs.
Depending if that is your actual target folder or something inside it, you can start by putting it as a property like this:
Hope it works for you!
Thank you the path I want will be in a Cloud the format from properties is (C:\Users\my name\One Drive-) my question is do I add that after the Environment.ExpandEnvironmentVariables(β%USERPROFILE%β)?
does the folder i need have to be in after Environment.ExpandEnvironmentVariables(β%USERPROFILE%β)
@mma - If the target folder is C:\Users\my name\One Drive-
, you must use Environment.ExpandEnvironmentVariables("%USERPROFILE%") + "\One Drive-\"
. Let me know if it works!
It worked thank you so much
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.