Save files which are drag and dropped to sepcific path

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
michael.heinrich
Posts: 4
Joined: Wed May 10, 2017 12:17 am

Save files which are drag and dropped to sepcific path

Post by michael.heinrich » Thu Jan 11, 2018 2:32 am

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!
Attachments
dragdropactivate.png
dragdropactivate.png (1.39 KiB) Viewed 308 times
Drag.png
Drag.png (5.87 KiB) Viewed 308 times

User avatar
jvierra
Posts: 12088
Joined: Tue May 22, 2007 9:57 am
Contact:

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

Post by jvierra » Thu Jan 11, 2018 6:10 am

Enumerate the "Lines" property of the RTB.

User avatar
michael.heinrich
Posts: 4
Joined: Wed May 10, 2017 12:17 am

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

Post by michael.heinrich » Thu Jan 11, 2018 7:01 am

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.

User avatar
jvierra
Posts: 12088
Joined: Tue May 22, 2007 9:57 am
Contact:

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

Post by jvierra » Thu Jan 11, 2018 7:04 am

You have to enumerate "Lines" because it is a collection .

"GetValue" is not a method on Lines.

User avatar
michael.heinrich
Posts: 4
Joined: Wed May 10, 2017 12:17 am

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

Post by michael.heinrich » Thu Jan 11, 2018 7:17 am

Sorry what do you mean by enumerate lines?

User avatar
jvierra
Posts: 12088
Joined: Tue May 22, 2007 9:57 am
Contact:

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

Post by jvierra » Thu Jan 11, 2018 7:28 am

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 $_"})

Locked