Move file from download with condition

Hi guys,

i couldnt get my move file to my directory may i know why ?

FilesfromDir=Directory.GetFiles("C:\Users" + System.Environment.UserName + "\Downloads")

FilesFromDir i set as String

then in my for each
File in FilesFromDir
i list a if condition to set that
FilesfromDir.Contains(“example.xlsx”) etc which i have mutlple of and i use the and/or condition

then in my move file i write something like this
am i doing something wrong ?? cos my move file didnt move my excel file to the file path i wanted

Hi,

I think this should be as the following. (Please add backslash after C:\Users

Directory.GetFiles("C:\Users\" + System.Environment.UserName + "\Downloads")

Or the following might be better to prevent this error.

Directory.GetFiles(System.IO.Path.Combine("C:\Users",System.Environment.UserName,"Downloads"))

Regards,

I have try change my directory file however my move file still don’t move my multiple excel file

@xxGoRpa

Check the filepath for the File.ToString

Usually in FilesfromDir it shouldbe Directory.GetFiles("C:\Users\" + System.Environment.UserName+ "\Downloads")

above \ is missing, can you check and let us know

Thanks,
Srini

Directory.GetFiles("C:\Users" + System.Environment.UserName + “\Downloads”)

yes i have check i am using it

"Users\ "

@xxGoRpa

Okay then you can write the condition as below

Path.GetFileName(File) = “User Maintainance Report.xlsx” OR you can put your next logic same as the one which we declare

If this is also not working then you have to debug and check where it is getting issue

Thanks,
Srini


I am getting this ? in my if condition

@xxGoRpa

For Each you can check the properties as TypeArgument and change that Object to String

If you are not able to find the TypeArgument then write as Path.GetFileName(File).Tostring = your value

Thanks,
Srini

i have try this however i still cant move in with 1 file …

@xxGoRpa

You have place .ToUpper to the String and you are trying contains again which is making no sense

Try as File.ToString.ToLower.Contains("similar itqs issued report.xlsx)

Hope this may help you

Thanks,
Srini

I have try however my file still does not moved to the destination folder …

@xxGoRpa

.Tolower will convert all the values to a lower case, and you are comparing with Similiar ITQs which always make false

You have put all in lower case and try as similar itqs issued report.xlsx

Thanks,
Srini

Thanks it work now after uppercase all need to upper or lower need to be smaller … LOL

@xxGoRpa

That’s nice, Glad it helped for you
Please click Mark as solution for appropriate post
So that others can benefit

Thanks,
Srini

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