Move file from specified date folder to URL/sharepoint

So here is what I have I am trying to move a file “M:\Weekly Reports Open Reqs+Date.Now.ToString(“yyyy”)+Date.Now.ToString(“MMMM.yyyy”)\Open Req Weekly Upload\OpenReq Rhyan (date).xlsx”
to
https://ENTERYOURURLHERE\PRO III Daily Planned Report +date.now.tostring(MM.dd.yyyy).xlsx”

but i dont think im using the date.now.tostring correctly. basically I will have a file that will rund aily and where i have the MMMM is where i need it to pull the full name of the month EG: July, and where MM is i was told would be 07.23.2019. Could be wrong, i dont know.

HELP!!!

Hello @rhyan.brandt,
Try these to build your path.

Local File Path:
String.Concat("M:\Weekly Reports Open Reqs", DateTime.Now.Year.ToString, DateTime.Now.ToString("MMMM.yyyy"), "\Open Req Weekly Upload\OpenReqRhyan(date).xlsx")

Sharepoint URL:
String.Concat("https://ENTERYOURURLHERE/PRO III Daily Planned Report", DateTime.Now.ToString("MM.dd.yyyy"),".xlsx")

@rhyan.brandt

Will look like: M:\Weekly Reports Open Reqs2019July.2019\Open Req Weekly Upload\OpenReq Rhyan (date).xlsx

  1. You can combine the two Date.Now functions into one: Date.Now.ToString(“yyyyMMMM.yyyy”)
  2. Windows might have a problem with the filepath having a period in it, I don’t remember if it bans that or not. If so, you should remove it from the date formatting.
  3. You may want to add some spacing around the date so it’s not pushed right up against the other words in the filepath.

Then, to put the file on a sharepoint URL you should install the UiPath Team Sharepoint Activities package from the package manager. The Move File activity is for moving files locally, I don’t think it works with a sharepoint URL (I’ve never tried - it might work great). I’ve never used the Sharepoint activities, but it looks like there is one called Upload File that should do the trick.

As far as formatting goes:
yy - 19
yyyy - 2019
dd - 23 (adds a zero for single digit days)
d - 23
MM - 07
M - 7
MMM - Jul
MMMM - July

There’s a lot more, but these are the relevant ones.

thanks for all the help, I tried to download the sharepoint activities package but got this error

07/23/2019 13:48:41 NU1202: Package SharePoint 15.0.0 is not compatible with net461 (.NETFramework,Version=v4.6.1). Package SharePoint 15.0.0 supports: microsoftsharepoint (Microsoft.SharePoint,Version=v0.0)

this almost worked however i have a folder called 2019 and one that is july 2019

so it would read M:\Weekly Reports Open Reqs\2019\July 2019\Open Req Weekly Upload

however the reason i need this is because this will be an ongoing report month after month, year after year

This string concat should return what’s in the quote below.

String.Concat("M:\Weekly Reports Open Reqs\", DateTime.Now.Year.ToString, "\", DateTime.Now.ToString("MMMM yyyy"), "\Open Req Weekly Upload")

I appreciate all your help, only one more question I have file that are labeled as such

M:\Weekly Reports Open Reqs\2019\July 2019\Open Req Weekly Upload\Open Req Rhyan 07.23.2019

how would i right that for current date

now im using the copy file and then I am dumping into the sharepoint…

once again thank you for all your help

DateTime.Now.ToString(“MM.dd.yyyy”)

negative my friend…

i get this error

19.7.0+Branch.master.Sha.8c253d13718eed5c7db27daef6facd1fe1b0d067

Source: Move File

Message: Cannot find a matching quote character for the character ‘"’.

Exception Type: System.FormatException

RemoteException wrapping System.FormatException: Cannot find a matching quote character for the character ‘"’.
at System.DateTimeFormat.ParseQuoteString(String format, Int32 pos, StringBuilder result)
at System.DateTimeFormat.FormatCustomized(DateTime dateTime, String format, DateTimeFormatInfo dtfi, TimeSpan offset)
at System.DateTimeFormat.Format(DateTime dateTime, String format, DateTimeFormatInfo dtfi, TimeSpan offset)
at System.DateTimeFormat.Format(DateTime dateTime, String format, DateTimeFormatInfo dtfi)
at lambda_method(Closure , ActivityContext )
at Microsoft.VisualBasic.Activities.VisualBasicValue1.Execute(CodeActivityContext context) at System.Activities.CodeActivity1.InternalExecuteInResolutionContext(CodeActivityContext context)
at System.Activities.Runtime.ActivityExecutor.ExecuteInResolutionContext[T](ActivityInstance parentInstance, Activity1 expressionActivity) at System.Activities.InArgument1.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance activityInstance, ActivityExecutor executor)
at System.Activities.RuntimeArgument.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance targetActivityInstance, ActivityExecutor executor, Object argumentValueOverride, Location resultLocation, Boolean skipFastPath)
at System.Activities.ActivityInstance.InternalTryPopulateArgumentValueOrScheduleExpression(RuntimeArgument argument, Int32 nextArgumentIndex, ActivityExecutor executor, IDictionary2 argumentValueOverrides, Location resultLocation, Boolean isDynamicUpdate) at System.Activities.ActivityInstance.ResolveArguments(ActivityExecutor executor, IDictionary2 argumentValueOverrides, Location resultLocation, Int32 startIndex)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

This appears to be malformed string error. Please check your string construction. I have noticed that the quotes don’t get formatted properly when copying text from a browser. You might want to delete the retype the quotes.

Try this
String.Format("M:\Weekly Reports Open Reqs\{0}\{1}\Open Req Weekly Upload\Open Req Rhyan {2}.xlsx", DateTime.Now.Year.ToString, DateTime.Now.ToString("MMMM yyyy"), DateTime.Now.ToString("MM.dd.yyyy"))

This return the following string
M:\Weekly Reports Open Reqs\2019\July 2019\Open Req Weekly Upload\Open Req Rhyan 07.24.2019.xlsx

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.