lilgirl Posted January 25, 2004 Posted January 25, 2004 Hi, I have files stored on an http server. I want to click on a button in vb.net and have it list all the file names on the server directory. Is there a way to do this. The directory I want to access is: something like http://123.45/folder/ Thanks. Quote
hog Posted January 25, 2004 Posted January 25, 2004 I don't know how to do this, but would be interested in how it would be done. Could be handy:) Quote My website
NK2000 Posted January 25, 2004 Posted January 25, 2004 that depends on that http server if this server offers directory listening then you can simple get the html code and parse it if not then there is only a possibility in getting the html code of one of the pages and go to all links which belong to that server generally said you have to parse a lot of things which isnt that difficult if you find some points which indicates a start and stop and so on an example for directory listing would be: http://www.apache.org/dist/ there you see folders and files then you just have to go through each line and check the symbol before the name of the folder/file a folder symbol indicates a folder and a all other symbols indicate a file have fun :) Quote
lilgirl Posted January 25, 2004 Author Posted January 25, 2004 thanks for your reply. what i tried to do was have vb.net look through the server files the same way it looks through files on my computer. For example: Dim files() As String = IO.Directory.GetFiles("http://199.98.xx.xx:xxxx/beams/") However, when I try to run this, it says URIs not supported. Is there some other class or function that would allow me to do this? Thanks. Quote
sde Posted January 25, 2004 Posted January 25, 2004 i don't have any code for you, but here is another way of accomplishing this. i've done something similar. if the remote server supports asp.net, php, or any server-side scripting, you could probably write a script which reads the directory and prints each file on a new line. for example we will call this script: dir.aspx ... when called, it would look something like this: file1.zip file2.zip someotherfile.zip so then you can make your vb.net application read: http://123.45/folder/dir.aspx and build an array of files based on that text. sorry i don't have code for you, just the logic. i wrote a .net windos app which does this, but i'm using php on the remote server to print out the files in the directory. hope this helps. good luck. Quote codenewbie
lilgirl Posted January 25, 2004 Author Posted January 25, 2004 thanks for the idea, sde. using php on the server side, would i also be able to edit and delete files on the server using my application because I will also need to do that. Thanks. Quote
sde Posted January 25, 2004 Posted January 25, 2004 i suppose you could send a variable to the script, like: http://host/folder/dir.php?action=delete&file=a.txt then you would use php to delete the file ( unlink(filename); ) the directory would have to be '777' to allow php to delete files though. this code would be something like: <? if($action == "delete") { unlink($file); } ?> i'm not sure what type of files, but once you have the file names, you could download or read the files, then you could edit them in your .net app, and overwrite them back up to the server. you would need to make an upload method. the directory will already be '777' permissions, so that should cover you there. Quote codenewbie
NK2000 Posted January 25, 2004 Posted January 25, 2004 oh i thought you want to get the files of a host which you dont own i could write something like a directory listing in php for you if that is a problem.. so the parse way is only for hosts you dont have access Quote
lilgirl Posted January 25, 2004 Author Posted January 25, 2004 thanks...i will have to look for tutorials on php now i guess..if you have any quick helpful links or sample code, i would appreciate it. thanks again! Quote
NK2000 Posted January 25, 2004 Posted January 25, 2004 PHP code Quote <?php if ($handle = opendir('.')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo "$file<br>"; } } closedir($handle); } ?> that is just a simple way to display all files :) Quote
lilgirl Posted January 31, 2004 Author Posted January 31, 2004 i am now wondering how i can display the files and directories on the server in the folder browser dialog box...anyone know if there is a way to do this? thanks! Quote
NK2000 Posted February 1, 2004 Posted February 1, 2004 "folder browser dialog box" what is that? Quote
lilgirl Posted February 1, 2004 Author Posted February 1, 2004 the folder browser dialog box is a component of visual studio 2003 that allows the user to select a directory in a dialog box..similar to the file dialog box..except it only shows directories. so what i want to do is display the directories on the ftp server in that dialog... any ideas are appreciated. Quote
NK2000 Posted February 1, 2004 Posted February 1, 2004 ah i think i understand you, what about building your own one? a treeview could be quite helpful here :) Quote
Hughng Posted February 1, 2004 Posted February 1, 2004 Don't use the class. It is buggy and will crash your application if selected path length > 135 characters (very unpredicatable when it will crashed). Quote
NK2000 Posted February 1, 2004 Posted February 1, 2004 which prooves my idea to build an own one :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.