Make web browser accept only file paths?

You could let them use the OpenFileDialog to browse to existing file, then Navigate to that path.
 
check the passed string from textbox. If it contains anything like .com, .net, .org etc. give a message saying "Invalid File"
 
so...something like
VB.NET:
Expand Collapse Copy
If textbox1.text = * + ".com" then
MsgBox("Not a file Path")
ElseIf textbox1.text = * + ".org" then
Msgbox("Not a file path")
Elseif Textbox1.text = * + ".net" then
MsgBox("Not a file Path")
Elseif textbox1.text = "http" + * then
MsgBox("Not a file Path")
End If
 
you could use textbox1.text.contains() method.

if(textbox1.text.contains(".com") or textbox1.text.contains(".org") then
msgbox("invalid file")
end if

the only problem can be if the document has .com or .org in it.
 
You can validate that the file exists: File.Exists Method (System.IO)
Remember to provide a OpenFileDialog also for people that don't want to type or copy/paste the file path.
 
Back
Top