Creating file with unique name without attempting to do it with every file?

Greeting People,

I needed to perform certain task on the given project.

Doubt.zip (1.1 MB)

  • I am opening the calculator from the start, do some calculation and get some value
  • Opening word pad and pasting that value in this word file.
  • closing calculator and saving the word file on the desktop
  • name of the file will be unique (lets say it is Document0.txt)
    -if i run this project again it must be (Document1.txt)
    -Again running it shows (Document2.txt, Document3.txt, and so on…)
  • So i have created it in such a way that it attempts to save the file from Document0 everytime

But this solution is undesirable, so i need the project to create a unique solution. ie directly store it as “Document4.txt” without checking with Document0, Document1 etc


I KNOW I HAAVE COMPLETED almost everything, but stuck in this part where uipath must recognize all the files on the desktop and create a new Document(counter).txt file everytime.

Thanks in advance,
ERROR

1 Like

How about simply listing the files in the path using Directory.EnumerateFiles(String, String)

This way you can determine which filename is available before attempting to write the file.

You already asked this before and got a couple of smart ideas:
-Instead of using numbers, use timestamp since you don’t have to do any check about the name being unique.
-Getting a list of names of file in the directory and extracting the highest number (similar to @qbrandon’s suggestion).

Please take some time to try them before posting the same problem in a different way.

1 Like

bro actually thing is, that file name can not be created with time stamp. bcoz. its not possible.

The sample in this reply works fine for me.


But you need to change the filename to include the directory you want (or just use "UiPath"+DateTime.Now.ToString("ddMMyyyyhhmmss")+".txt" to create in the .xaml’s location).
Then every time you run the workflow, a different filename will be used (depending on the timestamp).

1 Like

Can you share the Xamal file.

please check your xaml file properly

please don’t sat it’s not possible, all the log files and screetshots we will create using date time stamp.

I have attached my xaml file in the begining of this post. please find it there.
Doubt.zip

hello frriend, i am asking you to share me xaml file to check why you couldn’t able to create file with name includes time stamp.

Well, I am getting confused here,
If you need access to my xaml file. Its there in the doubt.zip file.

but if you talking about providing you with just the snapshot, please tell me that.

there you have written with ““Document”+count.ToString” but you are saying you cannot able to use ““Document”+DateTime.now.Tostring()”. i am asking you to share that workflow where you failed to create with date stamp.

sorry if it was included in this workflow, i couldn’t able to find please share me screenshot.

ok, now i get what you mean
so i have been working on this small error for a while now and i tried multiple logics
Ithe one which i shared doesnt have that datatime.now,tostring thing.
but i tried it after i got some people saying it to me…
also i dont remember what exactly was the error.
i will surely let you know about it. can you plz give me your email or maybe whatsapp(if you dont mind)
I would like to keep you updated with my progress. I am handed ove rthe huge project, so i can use a help hand. please do respond. eagerly waiting

initialize the count as 0 and then in the loop increment it.