upload and download to Ftpserver in a asp.net website - c#

I am designing a website and in one of my website page I want to access to a local Ftp server and upload and download files from it but I dont know how to design it like a list and how to download and upload and delet Files From Ftp would u plz guide me?

You can use the FtpWebRequest class to do this. I think you should try to get a list of files before you do any uploading/downloading, as a read is usually the easiest to do.
You can see how to get a directory list here.
Also, do not think of this as a asp.net "thing". It's part of the .Net framework. Create a service (or dal/repo) - a class which is responsible for handling your ftp calls. This way you can decouple it from the rest of your code.
You can then use a TreeView to show the contents of your ftp.

Related

IIS 6 restrict direct file access through URL

I have developed web application in mvc6. I am uploading pdf files and storing it in the UploadedFile folder. I am trying to restrict direct access through URL. for eg, i am able to open file using below url without login also.
http://192.168.0.118:50814/UploadedFile/1005_Visa_fhgfg_20160731.pdf
This is really dangerous. I disabled .pdf files in request filtering but i want to open those files inside the web application. I tried in many ways but could not resolved. Can anyone tell me what is the approach to fix this? If it is in controller level i would have been fixed. But here direct access is possible. Thanks in advance.

Uploading files to IIS server

I just wanted to ask is it possible to upload files to IIS server? If it's possible please describe me how to do it, thanks. I've been using google since 1h and i found nothing.
If all you need is file upload to your web server, you could set up FTP on your server
http://www.iis.net/learn/install/installing-publishing-technologies/installing-and-configuring-ftp-7-on-iis-7
If you are looking for a file upload capability for your web application, you can use the FileUpload control. The file would be POSTed to your page once you submit your form. The MSDN page has a an example of how to use the control and save the file on the server side.
Create a web application that has file upload capability
Host the web application in IIS.
Files uploaded will be dropped in your applications folder.
Take a look at for an example of file upload with WebApi: http://blogs.msdn.com/b/henrikn/archive/2012/03/01/file-upload-and-asp-net-web-api.aspx

How to get list of folders from a website

how can i get a list of folders from a website?
Namely I wrote a program that take a URL
And give a list of folders from the website.
I try
Directory.GetDirectories(myURL)
but it not work.
Generally, you will have to have the server run some code to get the list of directories. The client does not have access to the filesystem of the web server, and even using FTP or WebDAV the scope of what can be seen by the client will be limited.
The easiest way would be to create a folders.txt file in every directory on your web server with the name of all child directories. Then use your favorite HTTP API to download the file and parse its contents.
As for websites that are beyond your control: you can't. However you can check if you have access to a folder with a specific name. That should give you some ideas.
You can't directly access the file system on the web server (a .NET security feature). You can however do this when you're running locally (under localhost), but I understand that's not the point. If you're talking about submitting an URL that you don't own, then typically, no, that's not possible.

ASP.NET -Search and access local disk or network files in web

How can i search and download local disk files from web?
some codes available for searching local disk files by C#. but not web based....
please help me friends for searching algorithm..
Thanks,
regards,
Raj.
I can suggest you some asp.net web File Browsers, like ckfinder and a source code from codeproject.
http://ckfinder.com/
http://www.codeproject.com/Articles/301328/ASP-NETUser-Control-File-Browser
From the moment you select your file, you can simple click on it to get it, or use a http handler to send it to the client.

Is it possible to upload files in a website server not set-up in FTP in ASP.NET?

I'm creating a web tool in ASP.NET(c#) which can upload images to different sites and one of the sites is not set-up in FTP. Is it possible to upload files in the that site(with credentials)? If it is, can you please enlighten me on the process?
Thanks...
You could look at creating an image admin page which uses the FileUpload control.
Take a look at the fileupload control. It allows the user to do exactly that.
You can use the FileUpload control. But it will only allow upload data to the web server.
But if you need to save file to a different server, you will probably need handle the POST request.
I think this article about Writing Server-Side Upload Code may help you.

Categories