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.
This topic is 6 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
michael.heinrich
Posts: 8
Last visit: Tue Mar 12, 2024 6:05 am

Save files which are drag and dropped to sepcific path

Post 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!
Attachments
dragdropactivate.png
dragdropactivate.png (1.39 KiB) Viewed 2181 times
Drag.png
Drag.png (5.87 KiB) Viewed 2181 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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

Post by jvierra »

Enumerate the "Lines" property of the RTB.
User avatar
michael.heinrich
Posts: 8
Last visit: Tue Mar 12, 2024 6:05 am

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

Post 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.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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

Post by jvierra »

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

"GetValue" is not a method on Lines.
User avatar
michael.heinrich
Posts: 8
Last visit: Tue Mar 12, 2024 6:05 am

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

Post by michael.heinrich »

Sorry what do you mean by enumerate lines?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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

Post 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 $_"})
This topic is 6 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked