Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.5k views
in .NET FTP by (200 points)
Hi, just started using the C# version edtftpnet-1.1.6, and am finding it to be a very well organized FTP client. However, I'm having a little trouble with uploading a file, and would appreciate any advice that might help.

(I've already seen a few threads that look as though they may be related to what I'm seeing, but I'm not quite sure; so I hope no one minds me asking explicitly about my own case.)

I'm developing on WinXP Pro, using C# from within Visual Studio .NET 2003. I've configured IIS to provide a default FTP site, and have had no problems with uploading a file to this site using:

Put("simple.txt", "simple.txt")

I can also upload again, and the file gets overwritten.

What I really want to do, from an aspx page, is to allow the user to select a file using an OpenFileDialog component, then pass the filename from the dialog into the Put method. However, when I do this, I can't get it to work.

Current error message is:

"An unhandled exception of type 'EnterpriseDT.Net.Ftp.FTPException' occurred in edtftpnet-1.1.6.dll

Additional information: C:\Documents and Settings\EdRon\My Documents\simple.txt: The filename, directory name, or volume label syntax is incorrect."

I've also tried escaping the slashes, but to no avail.

I'd prefer to stick with the aspx page for the UI, so is there any way that I should be able to get this to work? I don't mind switching to using a stream rather than a file, if that's a better approach.

Any advice very gratefully received!

Ron

4 Answers

0 votes
by (162k points)
Uploading a file from a web page to IIS doesn't require FTP - you POST the data using an HTML FORM.

What I really want to do, from an aspx page, is to allow the user to select a file using an OpenFileDialog component, then pass the filename from the dialog into the Put method. However, when I do this, I can't get it to work.
0 votes
by (200 points)
I know about HTML forms, but I'm developing an FTP utility for a specific purpose. I will be uploading and downloading files, amongst other things. No idea what the set of web servers might be at the far end (IIS might feature).

From what I've done so far, I can get it to work using streams - but I want to know if there's a better way using FTP, and directly working with local and remote filenames.
0 votes
by (162k points)
You can't use an FTP client to put/get to a webserver, only an FTP server. You can of course use an FTP client in the webserver to put/get files to another machine's FTP server.

I know about HTML forms, but I'm developing an FTP utility for a specific purpose. I will be uploading and downloading files, amongst other things. No idea what the set of web servers might be at the far end (IIS might feature).

From what I've done so far, I can get it to work using streams - but I want to know if there's a better way using FTP, and directly working with local and remote filenames.
0 votes
by (200 points)
Ah, now I see what you mean. :)

OK, here's what I'm doing: I have a club website, with several non-technical people in charge of maintaining the content of various areas. We have a set of static HTML pages that I maintain, with updates to a "Latest News" page every few weeks. However, for team news, committee minutes, and things like that, it's better for us to have some autonomy and allow different people to upload documents as and when they become available. To allow some degree of navigation, I'm implementing a simple form of augmented browsable directory index page, which associates each uploaded file with a description provided by the responsible person at upload time. To enforce this, and to allow me to restrict the areas that each person can update, I'm distributing a small utility that will be given to different area "owners", so it will be possible to have a 2nd level of special interest document directories. Doing it this way (instead of using a GP FTP client such as SmartFtp) also allows me to encrypt the password.

We have no fine-grained control over our webite hosting, but I do have FTP access for maintaing the content, which works fine for the "main pages" (i.e the content other than the files that the users will be able to upload). The utility I'm developing will use the same FTP access for uploading files. In other words, it runs on client PCs (not on the website server). It already works fine, and dynamically builds the index page; but I'm using streams in the Put/Get API calls, as I was getting errors with the filename overloads of these methods. Being unfamiliar with streams, apart from Filestream classes from my Delphi VCL days, I was finding this a bit heavy going, and quite messy.

I'm interested to know if there's an easy way to get this to work using filenames, but in the meantime I've bound together the uploadable documents with their descriptions in an abstract WebsiteDocument class, which has descendants LocalDocument and RemoteDocument, and I've also added an FTPHelper class, to wrap the Put & Get. With these additional classes, none of my business logic (now there's an exaggeration) has to deal with streams any more, which was my initial concern.

Categories

...