Get DataGridView to accept file drop from mapped drive
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.
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.
- code20runner
- Posts: 20
- Last visit: Thu Jul 28, 2022 11:52 am
Get DataGridView to accept file drop from mapped drive
I have a project where I can drag and drop files and folders from a local drive to a DataGridView and everything works as expected. However, when I attempt to do the same with files from a mapped drive (UNC Path shared directory), the program locks up. How would I go about achieving this task?
- code20runner
- Posts: 20
- Last visit: Thu Jul 28, 2022 11:52 am
Re: Get DataGridView to accept file drop from mapped drive
Two issues with debugging. 1. My code machine is not attached to a network where I can test the UNC path issue. 2. New to PowerShell Studio and not sure how to get the correct properties you mention.
- code20runner
- Posts: 20
- Last visit: Thu Jul 28, 2022 11:52 am
Re: Get DataGridView to accept file drop from mapped drive
Ok. I got a mapped drive on my code machine. I ran the debugger but when I drag and drop a file from the mapped drive onto the DataGridView in my application, the debugger doesn't report any issues, it just locks up.
Below is my code for the DragDrop:
Below is my code for the DragDrop:
- $CollectDGV_DragDrop = [System.Windows.Forms.DragEventHandler]{
- foreach ($filename in $_.Data.GetData([Windows.Forms.DataFormats]::FileDrop)) # $_ = [System.Windows.Forms.DragEventArgs]
- {
- $eachFile = Get-ChildItem $filename -Recurse
- foreach ($truefile in $eachFile | Where-Object { !$_.psiscontainer })
- {
- $size = [math]::Round($truefile.Length / 1MB, 1)
- $CollectDGV.Rows.Add($truefile.FullName, $size)
- }
- }
- $CollectStatusBar.Text = ("List contains $($CollectDGV.Rows.Count) items")
- }
- code20runner
- Posts: 20
- Last visit: Thu Jul 28, 2022 11:52 am
Re: Get DataGridView to accept file drop from mapped drive
I don't see any breakpoints showing up or anything to indicate where the problem is located.
- code20runner
- Posts: 20
- Last visit: Thu Jul 28, 2022 11:52 am
Re: Get DataGridView to accept file drop from mapped drive
Thanks for the guidance. However, my main issue isn't with debugging at the moment, it is understanding how to deal with/implement UNC Paths and DataGridViews.
Re: Get DataGridView to accept file drop from mapped drive
No idea what is meant by "implement UNC Paths and DataGridViews". A DataGridView does not know anything about UNC paths. Are you askng how to display a UNC path in a DGV?
- code20runner
- Posts: 20
- Last visit: Thu Jul 28, 2022 11:52 am
Re: Get DataGridView to accept file drop from mapped drive
I figured out the issue of the application locking up when I drag and drop a file from a mapped drive to the DataGridView box. I had to ensure I was using the -LiteralPath option and not the -Path option. All seems to be working now.