Ler arquivos de um diretório e escrever o nome em uma planilha Excel - Read files from a directory and write the name on an Excel spreadsheet

Oi!
Pessoal, existe alguma forma em que eu consiga ler o nome dos arquivos de um diretório e ler isso no excel? A ideia é que a cada novo arquivo, o excel acrescente uma nova linha com o nome do arquivo.

Hi!
Guys, is there any way I can read the name of files in a directory and read this in excel? The idea is that with each new file, excel will add a new line with the file name.

@danielle.freitas …please check this post…

Thank you!
I did the steps in that post, but it is giving an error.


Obrigada!
Fiz os passos mencionados nesse post, mas está dando um erro.

Error:
Main.xaml: Compiler error(s) encountered processing expression “Directory.GetFiles(“C:\Users\FreitaD2\Documents\SAP\SAP GUI”)”.
‘Directory’ é ambíguo, importado dos namespaces ou tipos ‘Microsoft.Graph, System.IO’.
Main.xaml: Compiler error(s) encountered processing expression “Directory.GetFiles(“C:\Users\FreitaD2\Documents\SAP\SAP GUI”)”.
‘Directory’ é ambíguo, importado dos namespaces ou tipos ‘Microsoft.Graph, System.IO’.

@danielle.freitas - Share what you have typed in Directory.GetFiles…send the entire code…

@danielle.freitas - Please share the xaml.

Main.xaml (31.2 KB)

Problem solved!
I used only For Each and now it worked.
Thank you!


Problema resolvido!
Usei apenas o For Each e agora funcionou.
Obrigada!

image

@danielle.freitas - I was about to respond…I just fixed your xaml.

Good that you fixed…If its solves your query. Please mark my post solution , that will close this thread.

How can I declare this variable in this case?


Como eu posso declarar essa variável nesse caso?

@danielle.freitas - Inside Excel Application scope…you just have to give “File”…

which has the file name…you just printed the value in the message box right?

I dont know what is your requirement…I already gave you the xaml…not sure you downloaded or not?

Here you go: FileNames_ToExcel.zip (41.5 KB)

ok, it worked well!


ok, isso funcionou bem!

image

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