Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using the Web Browser component to function as a file explorer. What I am looking to do is store the file name of the selected file(s) in a variable. Example: If a user navigates to C:\SomeFolder and selects File.txt from that folder, I want to be able to store "File.txt" to a variable for future use (say, deleting said file). I need that variable to change on the fly based on whatever file the user clicks on. Any help would be greatly appreciated.

What I have tried:

I have been searching the Googles all morning, but, so far, I have not found a solution. I have looked into GetFileName, but I am not sure how to make that work on mouse clicks.
Posted
Updated 14-Sep-18 6:10am
Comments
Richard Deeming 14-Sep-18 10:49am    
Why are you using a WebBrowser control instead of an OpenFileDialog?
kwatkins1037 14-Sep-18 10:57am    
The point of this application is not to open files, but to transfer them (think WinSCP). Due to security constraints, I cannot install WinSCP on the server. However, since the client has requested something similar (and locked down to specific location) I have created my own version. The only thing I have conquered is selecting a file and then clicking a delete button.
littleGreenDude 14-Sep-18 12:15pm    
I'm not sure I understand what you are trying to accomplish? You can't use an FTP/client and you want to move a file to the server. Is it an IIS webserver? Could you possibly use an Html 5 File upload approach? This link shows an example where it displays the filename back to the user. http://www.matlus.com/html5-file-upload-with-progress/

1 solution

Quote:
The point of this application is not to open files, but to transfer them (think WinSCP). Due to security constraints, I cannot install WinSCP on the server. However, since the client has requested something similar (and locked down to specific location) I have created my own version. The only thing I have conquered is selecting a file and then clicking a delete button.


The OpenFileDialog doesn't open anything - it selects a file and returns the info to your app so you can decide what to do with it.

Using a WebBrowser as a file selector is ... um ... using a sledgehammer to crack a nut.
 
Share this answer
 
Comments
kwatkins1037 14-Sep-18 13:03pm    
I think I'm doing a poor job of explaining what I'm trying to accomplish. We have two locations in a Citrix environment that a client needs to be able to transfer files between. One being the client's local C drive and a remote server. They need to be able to transfer any amount of files in either direction, and they need to be able to browse thru different directories on both sides. The best way to describe this would be to use WinSCP. Using WinSCP, I have a side-by-side view of my device and whatever remote device I'm connected to. I can bring files back and forth all day long. However, do to security policies, I cannot install WinSCP in the Citrix environment. However, this doesn't prevent me from writing something myself and putting it out there (I didn't write the security policy, so don't ask :) ). Everything about this app works. The functionality I'm asking about isn't even 100% necessary. If the client selects a file (or multiple files), and hits the Del key on their keyboard, it will delete what they selected. I was hoping to implement the same functionality into a button, in the app, that they can click (Del key as a clickable button). I hope this clears up what I am aiming for.

**EDIT: When writing programs/scripts for this client, I have found it best to assume the end-user has never used a computer before. I am trying to create something that is very user-friendly and easy to use.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900