Results 1 to 10 of 10

Thread: How To Use TCP To Count The Number Of Files In Server Folder?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2018
    Posts
    395

    How To Use TCP To Count The Number Of Files In Server Folder?

    Hello, I am looking to use TCP to return the value in this case number, of files in a specific directory on a server.
    Hoping someone can help me.

    Files on my file host, For example in a folder, I would like to get the number of files in a file path on the server.

    How can I achieve this what are my choices?

    Thanks
    Last edited by DreamWarrior77; Sep 17th, 2020 at 01:10 AM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,350

    Re: How To Use TCP To Count The Number Of Files In Server Folder?

    I think that you have unrealistic expectations of what TCP can do. It's just a communication protocol. If you want to know number of files on a server machine then you would need an application on that machine to count those files. There's no magic to that. How would you usually count files? That's how you would do it here. That server application would then need to accept requests from a separate client application. The client application would connect and make the request; the server application would do the work and provide a response. You can't just create one application and have it connect to a machine and magically get the information you want. There needs to be software running on that machine to gather and provide that information.

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,047

    Re: How To Use TCP To Count The Number Of Files In Server Folder?

    Can you see the files on the computer you want to get this count from?

    The reason I'm asking is that you talk about a server, but there are at least two different setups that you could be dealing with. Normally, you would connect to some service running on the server, and the service would return the information you requested. That's how JMC was interpreting your question, and it's certainly the most common setup. Such a thing would be the case if you were remoting into a system. However, it might also be the case that the server is sitting on some internal LAN that you can connect to directly, and possibly just map a drive to. In that case, you wouldn't have any need for TCP, as there would be simpler means. Of course, that would mean essentially that you could see the folder on the server the same way you could see a folder on your local computer, which is not usually what people mean when they talk about servers, and since you were already talking about TCP, then you probably do have the standard relationship with the server.

    The best way is to have a service running on the server that you connect to. Ultimately, that's how it would have to work.
    My usual boring signature: Nothing

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2018
    Posts
    395

    Re: How To Use TCP To Count The Number Of Files In Server Folder?

    So my understanding is that I can download files from the remote server but I can't count how many there are without a server side app?
    Which technically would mean that if I wanted and it is not the way I want to do it but I could just download all the files in this particular case small text files
    and then just count them after they are downloaded.

    ok well in this situation the server would be like a host like hostgator. It's Linux hosting, I only know some VB and I realize that I can't exactly create and run a VB Forms app on the server that I know of..
    so what would be the best and easiest way to create an app that can run on my Linux host. Since we can't use VB Forms Apps what is the next best thing I can do?

    Is there a way to run vb forms apps on Linux hosting?
    Last edited by DreamWarrior77; Sep 17th, 2020 at 12:33 PM.

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,047

    Re: How To Use TCP To Count The Number Of Files In Server Folder?

    What does the remote server give you as a means to download files? I'm a bit out of date, so I still remember FTP as the main method, but I don't believe that's true anymore. Do you give it a file name and it gives you back a file? Is there no means to get a list from the service, such as some form of *.*?

    The basic point is that the server clearly already has some service running that is giving you files, so it may well be that the service has the capability you seek. That would be ideal, but it might not be so easy to find.
    My usual boring signature: Nothing

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2018
    Posts
    395

    Re: How To Use TCP To Count The Number Of Files In Server Folder?

    There is a Method called DownloadFile:

    https://docs.microsoft.com/en-us/dot...ownload-a-file

    you can download a file like this:

    Code:
    My.Computer.Network.DownloadFile(
        "http://www.cohowinery.com/downloads/WineList.txt",
        "C:\Documents and Settings\All Users\Documents\WineList.txt")
    I am trying to use it but getting an error:

    System.Net.WebException: 'The remote server returned an error: (404) Not Found.'

    I changed the file path by the way because there was noting there, it went to microsofts website..
    so I have it set to my wordpress installation and a folder for example, with the text files in it but it is giving me this error.
    Why can't I access the file?

    The file is in fact is on the server when I go into cpanel and files, the folder and files are there but I can not access it directly by typing the URL in the browser and visiting it or by the vb app either.

  7. #7
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,047

    Re: How To Use TCP To Count The Number Of Files In Server Folder?

    Others will likely be able to answer better. I've never used that method. I'm wondering whether or not the 404 is being returned in error...of a sort. They may be returning a 404 rather than an Unauthorized. You didn't mention anything about supplying credentials, and I guess I'd be a little surprised if you could simply download any file from that site without some kind of authorization, but perhaps that wouldn't be needed for such a file.
    My usual boring signature: Nothing

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2018
    Posts
    395

    Re: How To Use TCP To Count The Number Of Files In Server Folder?

    Yes that was the impression I was under that it would work for certain types of files but you are right that it may be the case that it does maybe require credentials first.
    But for example when I go directly to the URL in a browser it just does not work. It says page not found on the wordpress site.
    If it was password protected it should pop up a password prompt right? Or maybe I just can't access files in this way?

    I don't really get it though, I remember just being able to go to file URL addresses and viewing or downloading them just like that.
    Why this? I bet it is just a wordpress security measure. I just don't know how to get around it.

  9. #9
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,047

    Re: How To Use TCP To Count The Number Of Files In Server Folder?

    Ideally, it should either give you an Unauthorized message, or let you provide credentials, as you say. However, some sites use 404 for pretty nearly everything. Somebody on here likely has some experience with Wordpress sites, though, and I do not.
    My usual boring signature: Nothing

  10. #10
    Frenzied Member
    Join Date
    May 2014
    Location
    Central Europe
    Posts
    1,372

    Re: How To Use TCP To Count The Number Of Files In Server Folder?

    so your initial question "get number of files from remote server using tcp/ip" turned more into: "get number of files from directory on remote wordpress webserver". while your first question is technically correct, the second one is alot more specific.

    My.Computer.Network.DownloadFile(
    "http://www.cohowinery.com/downloads/WineList.txt",
    "C:\Documents and Settings\All Users\Documents\WineList.txt")
    this client code talks to a http webserver (the server side piece of software - out of the box) that is configured to allow downloading of the file WineList.txt
    there is also a webserver function to allow browsing folders, i.e. display each filename, size etc of files in a folder. but this functionality is usually turned off nowadays.
    anyhow: you are using wordpress, which is your webserver. i guess you can configure wordpress to allow browsing a folder on the webserver. check wordpress docs, i myself have just a litte experience in wordpress. your client sw could then grab the html received from wordpress and count the listed files.
    the second option i cound think of is having some php script included in your wordpress setup that does the counting and gives the result. your client would then also get the html output of that php and get the number from there. this second option is more secure as you only open a very specific functionality on the web server to the public.
    but there are certainly also other possibilities to do what you want.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width