How do I download all files in a directory and all subdirectories on an HTTP server?
By using a command-line tool like wget rather than reinventing the wheel.
If directory browsing is enabled on the server then you can crawl the directory listings, i.e. Use HttpWebRequest to get the listing page, parse the response to find the file links, download each file (also with HttpWebRequest), navigate to each subfolder, rinse and repeat.
If directory browsing isn't enabled then you can't really download ALL files in ALL subdirectories because you can't know they exist.
However, you could still use HttpWebRequest to crawl the exposed web pages and download any linked files that are of interest.
Related
I have a problem - I cannot find my file when I open it using http://localhost:49652/.well-known/acme-challenge/FfI7Xeq7_QH5R5pCd3LhAkU4k3nOqBz9mNbvJ9EwMoQ although it exists and the path is correct.
I use ASP.NET C#, OS: Windows Server 2012 And IIS 8.0.
And error:
Help me... Please!
I want to forward you to an other question: What file extensions are blocked by default in IIS
The issue is that IIS has a configuration, how to handle requested files.
Depending on the extension, there have to be done different actions: While resources like .txt or .jpg files are just sent into the network as they are stored on the disk, other files like .aspx or .asmx have to be parsed, executed in dotnet and then the output have to be sent etc.
Other extensions like .dll or .exe are blocked by default, I think.
The problem is, that your files do not have any extension, so for this directory you have to configure that IIS should pass through all of the files.
Found another usefull link to microsoft: https://learn.microsoft.com/en-us/iis/configuration/system.webserver/security/requestfiltering/fileextensions/
I am trying to figure out how to copy the most recent file in a server directory to a local directory in c#.
I am needing to do this to over 100 directories. They will all copy and rename to the same local directory.
The directories all named: e.g. \ServerPath\01, \ServerPath\02, \ServerPath\03, etc.
Right now I have a batch script that will do it but it takes forever since it goes through each and every file in each directory.
My immediate thought was "Is this possible with Robocopy??" I did a quick search on Google for "Robocopy most recent file" and came up with a blog post about handling this with a powershell script.
This should at least provide you the latest files without you having to go through "...each and every file in each directory".
** Dumb questions alert **
I created my first Web API project. I would like to test it on my web host, but I can't figure out what files to upload. I tried to upload everything from the HelloWorld folder, but I get a 403 "Access is denied" error when I attempt to access the files.
Once I upload the folders/files, how do I access them? Do I have to navigate to the Root > Views > Home > ... ?
Folder Structure
HelloWorld
HelloWorld
_UpgradeReport_Files
1 css, 1 xslt, 4 pngs
HelloWorld
All of my folders and files
This is what I tried to upload
packages
A lot of ASP and JQuery folders
Thank you for your help.
I think you have two separate problems here: knowing what files to deploy and getting the permissions correct so that you can access them.
In general, the files you will need to deploy are all of your static files (images, CSS, Javascript, HTML), any .cshtml/.aspx/.ascx/.asax files, and Web.config. However, the easiest (and best) way to know what files to deploy is to use Visual Studio's publishing mechanism. Go to Build->Publish, and publish to a local directory. Open that directory, and you'll see all the files you need to deploy.
As far as the second problem, that's more complicated. The solution depends on the version of IIS, but the basic upshot is that you need to give the correct user access permissions to your file. Depending on your version of IIS and how it's confusing, it will either be IUSR, IIS_IUSRS, or NETWORK SERVICE. Try Googling for "file permissions IIS ".
I'm trying to download some files from a virtual directory using WebClient class and DownloadFile method, all files download good except files with .sql, .flag, .tmp, . InstallState extensions. I get the "HTTP Error 404 - File or directory not found" error. This extensions are not in the Application Configuration Mappings, so what do I have to configure in order to download this files? Because I can't figure it out. Thx. (I'm using windows server 2003 )
The reason for this is that the web server probably doesn't have MIME types configured for these file extensions.
Because these are being served as static files over HTTP you'll need to add them.
If these files are residing on a public facing server administered by you, do you think it's wise to be serving these? Why not obtain via FTP?
The problem is I reinstalled my computer and the backup didn't work so now all my sourcecode is gone... But my webservice is still running on a webserver.
When I upload the new website the old site will be deleted, so how can i backup the webservice and make it a part of my new website?
In the bin folder of the webserver there is some strange name files like App_web_cjcpmkr8.dll,
can I just download these files and .asmx files? Isnt there then missing a link between the files? How can I see which .asmx files uses which .dll files?
Unfortunately they're all compiled- depending on your site's config, there will be either one assembly per page or per directory. You can download all the DLLs and decompile them through reflector- the decompiled class names should help you match them up with the corresponding markup, but you'll still have some reconstructive surgery to do.
The magic link between the asmx and the dlls lies in the name of the bin folder. IIS will automatically look for dlls in this folder. You should be able to deploy your web service on a new web server by just copying the files. I recommend that you try to set up a copy of the service on a new web server, before you delete anything.
If this is critical data get a service to try and get your files back. If not then moving forward invest in an online backup solution / source control utility.
This will save you tons of time when this happens again. I use source control on a remote server combined with a subscription to Carbonite locally to ensure that I don't lose that precious data; both the data checked in and the data that I'm currently working on. It's Iike $45 a year and well worth it.
As for your data I'm sorry that you've lost it. I'm sure you’re not the first to have this happen.