How to verify that an SCP file upload was successful - c#

I've been given an assignment to use SCP to upload a file to a Secure FTP Server (I'm doing this using Workflow Foundation activities). I can upload the file OK, but I need to do some sort of validation to make sure that the file is, in fact, there.
Any ideas ?
Thanks,
Chew

I've solved this type of problem before by:
uploading the file to the server.
downloading it as a different file name.
running a local comparison of the two files.
A script to do this is relatively easy to set up.

Related

C# - How to temporary stream file online to be accessed URL

I have been working on project recently where eventually I need two (or more) applications on different machines to be able to access the same file on one of them without uploading it to a server first.
Thus, the best idea I could get was to create something like a mini-temporary file server where the desired file path is streamed over the ip address and the other machine can access it via a URL like that "http://xxx.xxx.xxx.xxx/path/file.ext".
I have a good experience with C# but this approach... I never stepped into before, so any help is appreciated either in achieving this approach or any other method that can lead to allowing cross-internet access to a file on a machine.
Thanks in advance.
[Edit]
This operation has to be done without prior port forwarding, I don't know if this is possible, but I guess if it is not then I might need to do something like streaming to a php server first or something, again any help is appreciated.
Set up a virtual directory pointing to a local directory in IIS.
Application A writes file to local directory.
Application B reads
file from http.
Otherwise, you could use a network drive for both applications to read/write from.

Uploading Files to Two Web Front End Servers - how to consolidate into one location?

I have built a web application which uses two web front end servers, the Users are randomly directed to either one through the same URL. The web app has specific functionality to upload and download files. When a file is uploaded, it is stored on a specific directory on the server to which it is uploaded.
The issue is that when a User uploads a file to the folder on Server 1, any user trying to download that same file from Server 2 will not be able to as it only exists on the server where it was uploaded.
What's the best way of solving this? I've looking at:
- Using a SAN, problem here is I don't want to change or create a domain
- Writing a Windows Service, would prefer to avoid this if possible, I've not done it before but will give it a go if necessary
Thanks in advance!
Joe
Unless I'm missing something very obvious, all you need is a shared location. This could be a network share addressed through a UNC path, a folder on an FTP server, a database, anything at all, as long as it's
shared,
accessible from both web-servers
web-application service account has read/write permissions to it.
From your requirements a network share on a file server (perhaps 1 of the 2 web-servers, or the load-balancer, or (ideally) a new server entirely) would be the simplest method.

Write And Read .txt files from FTP with C#

Is it possible to write a txt file on ftp (not upload a file to ftp!) Directly writing a txt file on ftp server) and read from a file on a ftp (not download a file from ftp!) Directly read from a txt file on ftp server? I searched but ı found upload a file and donwload a file with FtpWebRequest class. Note: FTP server uses credentials.
No, it is not possible.
The FTP protocol described in RFC 959 doesn't have any means to achieve what you want.
No, as far as I'm aware, your only option is to download or upload the file. I guess you could short-circuit it a bit by only downloading the file until you got to the part you needed, then aborting. But the whole purpose of FTP is to upload/download FILES, not content.
It's possible with help of third-party virtual file system driver which should be installed in system. There exist third-party applications which let you see the remote FTP location as a virtual disk on your computer. Once the remote FTP location is mounted this way you can use regular file I/O methods to read and write those files. You can create such application as well (not a rocket science with right tools).

Uploading files to Linux server from Windows C#

I have to write a C# program that only needs to work on Windows. It needs to allow the user to select a file to upload. That file will be uploaded to a folder on a remote Linux server. I know the username, password, and url for this Linux machine. Does anyone know how I go about connecting to the server and then uploading the file to it in a C# desktop application?
If you're going to upload over FTP, the FtpWebRequest should do the trick:
http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.aspx
So I came up with this answer before looking at the first response (David's). Interestingly, we came up with the same solution! An ftp upload was what I was looking for. I completely forgot about FTP.
MSDN also has this web page for a more succinct how-to:
http://msdn.microsoft.com/en-us/library/ms229715.aspx

How to correctly write dynamic files to an FTP server?

I'm using C# and i have written a locally installed application that dynamically generates files which need to be on an FTP server.
Do i generate them to disk then upload them to the FTP server? or is there a way to open a stream to an FTP server and write the files directly?
Check the code sample I gave in this answer, doesn't rely on writing to files. It's not SQL specific and was just a suggestion on how to use SQL CLR integration assemblies to upload output from sql queries to an FTP server. The for loop in the method is just to demonstrate writing to the FTP stream. You should be able to rework to you needs:
How to write stored procedure output directly to a file on an FTP without using local or temp files?
You should follow the class:
System.Net.FtpWebRequest
You will see that its arguments are streams and you can send data to them from any source.
When seaching for .Net capabilities you should be aware of the object browser for visual studio acessible in:
View > other windows > object browser
Is supplies a search over all known assembly .Net objects.
The better way is to save file locally, and upload it later, since there could be problems with upload process.
Since you are using c# I'm thinking maybe you are in a Windows Env. Something I know little about :)
If you are dealing with a unix env, you could just pipe your output thru SSH, which would also take care of encryption overhead.

Categories