Page 1 of 1

Save files which are drag and dropped to sepcific path

Posted: Thu Jan 11, 2018 1:32 am
by michael.heinrich
Hello together,

i want to save files which are dragged into a richtextbox to a dynamic path (depending on date in pathname).
How can i now save the dragged files to Disk by clicking on a button?

The script should be for documentations for example i should create a new user and for documentation reasons i want to drag and drop the mail with the instruction and a small documentation by me to a seperate folder.

I hope you unterstand and can help me.

Thank you in advice!

Re: Save files which are drag and dropped to sepcific path

Posted: Thu Jan 11, 2018 5:10 am
by jvierra
Enumerate the "Lines" property of the RTB.

Re: Save files which are drag and dropped to sepcific path

Posted: Thu Jan 11, 2018 6:01 am
by michael.heinrich
Hi. thanks for the fast reply.

i tried: Write-Host $richtextbox1.Lines.GetValue but thats thte output:
System.Object GetValue(Params int[] indices), System.Object GetValue(int index), System.Object GetValue(int index1, int index2), System.Object GetValue(int index1, int index2, int index3), System.Object GetValue(long index), System.Object GetValue(long index1, long index2), System.Object GetValue(long index1, long index2, long index3), System.Object GetValue(Params long[] indices)

It would be okay if i get the filepath to start a robocopy of the file but would be better if i can drag it into the richttextbox and directly save it out of the richtextbox by click on button.

Do you have any idea?

Sorry that topic is new to mew.

thank you.

Re: Save files which are drag and dropped to sepcific path

Posted: Thu Jan 11, 2018 6:04 am
by jvierra
You have to enumerate "Lines" because it is a collection .

"GetValue" is not a method on Lines.

Re: Save files which are drag and dropped to sepcific path

Posted: Thu Jan 11, 2018 6:17 am
by michael.heinrich
Sorry what do you mean by enumerate lines?

Re: Save files which are drag and dropped to sepcific path

Posted: Thu Jan 11, 2018 6:28 am
by jvierra
In PowerShell we enumerate collections in many ways. Enumeration is a fundamental of all programming and scriptin.

See: https://en.wikipedia.org/wiki/Enumeration

PowerShell uses foreach, ForEach-Object, for and other methods to enumerate collections.

$richtextbox1.Lines.ForEach({Write "This is a line $_"})