ftpwebrequest

Issue with FtpWebRequest getDateTimestamp and DateTime

孤街浪徒 提交于 2019-12-24 06:44:44
问题 I'm having a bit of trouble with a program that I'm writing. The program checks the date created of a file on a remote ftp site, then if it matched today's date it will download the file the upload it to another ftp site. I get the following error when I run the program: unhandled exception system.formatexception string was not recognized as a valid datetime Here is the code I'm using to convert the ftp file created date to a datetime /* Get the Date/Time a File was Created */ string

Uploading folder to ftp subfolder returns error (550) file unavailable, no access

荒凉一梦 提交于 2019-12-24 01:44:41
问题 I am trying to upload images to the ftp. I need to have it in a compressed folder called by a specific name and then upload that folder to a specific directory. Each time I try, I get an error The remote server returned an error: (550) File unavailable This code works fine when I am trying to upload one image at a time. Here I am trying to upload a whole folder. I checked the uri (I copied it from the debugging) and it went there just fine. Is there a different way that I have to do the

how to download compressed file (.zip) through FTP using c#?

余生长醉 提交于 2019-12-23 13:25:35
问题 How to download .zip file format using c# code? Here is the code, i am using to download. Just to highlight, If i download .txt file, it works fine. If i download .zip file, it downloads the .zip file but i can't open this. It complains that .zip is in incorrect format. I have doubt in how i am writing back the file on local drive. Help? string ftpServerIP = FTPServer; string ftpUserID = FTPUser; string ftpPassword = FTPPwd; FileInfo fileInf = new FileInfo(FileName); string uri = "ftp://" +

FTP upload file The requested FTP command is not supported when using HTTP proxy

不羁岁月 提交于 2019-12-23 07:36:00
问题 Can someone please take a look at the code below and tell me what I am doing wrong. I am just going in circles,,, any pointers greatly appreciated public class FtpWebRequestUtil { private static string RemoteHost; private static string RemoteFtpPath; public static NetworkCredential Credential = new NetworkCredential(); public FtpWebRequestUtil() { } public FtpWebRequestUtil(string RemoteAddress, string RemotePath, string RemoteUser, string RemotePwd) { Credential.UserName = RemoteUser;

How to move files in the FTP server

好久不见. 提交于 2019-12-22 19:46:12
问题 I want move files from a FTP server to another directory in the same server. I think the method that I have to use is Rename . Well, I can't continue because i don't know how. In put or get operations there are data stream but not here, that's my problem $ftprequest = [System.Net.FtpWebRequest]::create($Source) $ftprequest.Credentials = New-Object System.Net.NetworkCredential($user,$pass) $ftprequest.Method = [System.Net.WebRequestMethods+Ftp]::Rename $ftpresponse = $ftprequest.GetResponse()

Transfer files directly from FTP to Azure File Storage without keeping them locally in memory or disk

烈酒焚心 提交于 2019-12-22 18:33:26
问题 I have to transfer files from FTP to an Azure File Storage. My code works fine, but I'm transferring those files in memory which is not a best practice. So first I read the stream to an Byte array in memory. Then I upload the output to an Azure file storage. Now I know it's better to do this asynchronicaly. But I don't know if this is possible and how to do it. My code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using

FtpWebRequest ignores wrong password after previous successful connection using correct password

邮差的信 提交于 2019-12-22 11:37:15
问题 I have run into an issue when working with FtpWebRequest class in C#. When I try to upload a file to an FTP server using correct credentials for the first time and then wrong credentials (user name the same but wrong password) for the second time, there is no exception thrown and the file is still UPLOADED to the FTP server. Please consider the following code: using System; using System.Net; internal class Program { private static void Main(string[] args) { var uri = new Uri("ftp://ftp

Check if directory exists on FTP server

。_饼干妹妹 提交于 2019-12-22 03:54:13
问题 I'm running a check to see if a directory exists on my FTP server: public bool DirectoryExists(string directory) { bool directoryExists; var request = (FtpWebRequest)WebRequest.Create(directory); request.Method = WebRequestMethods.Ftp.ListDirectory; request.Credentials = new NetworkCredential("user", "pass"); try { using (request.GetResponse()) { directoryExists = true; } } catch (WebException) { directoryExists = false; } return directoryExists; } In this case: directory = @"ftp://ftp

Check file existence on FTP server in PowerShell

情到浓时终转凉″ 提交于 2019-12-21 06:24:28
问题 I want to check if some file exists on FTP server. I wrote code with Test-Path but it's not working. Then I wrote code to get FTP server file size, but it's not working either. My code function File-size() { Param ([int]$size) if($size -gt 1TB) {[string]::Format("{0:0.00} TB ",$size /1TB)} elseif($size -gt 1GB) {[string]::Format("{0:0.00} GB ",$size/1GB)} elseif($size -gt 1MB) {[string]::Format("{0:0.00} MB ",$size/1MB)} elseif($size -gt 1KB) {[string]::Format("{0:0.00} KB ",$size/1KB)}

Check file existence on FTP server in PowerShell

风流意气都作罢 提交于 2019-12-21 06:24:05
问题 I want to check if some file exists on FTP server. I wrote code with Test-Path but it's not working. Then I wrote code to get FTP server file size, but it's not working either. My code function File-size() { Param ([int]$size) if($size -gt 1TB) {[string]::Format("{0:0.00} TB ",$size /1TB)} elseif($size -gt 1GB) {[string]::Format("{0:0.00} GB ",$size/1GB)} elseif($size -gt 1MB) {[string]::Format("{0:0.00} MB ",$size/1MB)} elseif($size -gt 1KB) {[string]::Format("{0:0.00} KB ",$size/1KB)}