Topic "Edit Remote File Using .NET assembly"

Author Message
luismdmauricio
[View user's profile]

Joined: 2015-04-10
Posts: 3
Location: Portugal
Hello,

Is it possible to implement code using .net assembly, to do same action like in the FTP Client to EDIT a remote file?

I need to implement in my application a connection to a remote server, select a file, edit it and, when finished, upload it back to the remote server. That's exactly what is donne in the "Edit With" option of the WinSCP Client Application.

Thanks in advance.
Best regards
Advertisements
InteXX
[View user's profile]

Joined: 2009-05-17
Posts: 21
Location: Fairbanks, Alaska
luismdmauricio wrote:
Hello,

Is it possible to implement code using .net assembly, to do same action like in the FTP Client to EDIT a remote file?

I need to implement in my application a connection to a remote server, select a file, edit it and, when finished, upload it back to the remote server. That's exactly what is donne in the "Edit With" option of the WinSCP Client Application.

Thanks in advance.
Best regards

You might want to try downloading, editing, and then uploading:

http://winscp.net/eng/docs/library#using_classes_from_winscp_.net_assembly

Jeff Bowman
Fairbanks, Alaska
luismdmauricio
[View user's profile]

Joined: 2015-04-10
Posts: 3
Location: Portugal
Hi, thanks for the repply

I forgot to mention that its an asp.net application, so I need to open the file directly from a local folder from within asp.net application. All examples that I saw in web are for download file not to open it.

Thanks
Best regards
InteXX
[View user's profile]

Joined: 2009-05-17
Posts: 21
Location: Fairbanks, Alaska
luismdmauricio wrote:
Hi, thanks for the repply

I forgot to mention that its an asp.net application, so I need to open the file directly from a local folder from within asp.net application. All examples that I saw in web are for download file not to open it.

Thanks
Best regards

Here you go, try this:

Code:
Public Class Welcome
  Inherits Page

  Protected Sub Page_Load(Sender As Object, e As EventArgs) Handles Me.Load
    ' First use WinSCP to download your file from the server

    ' Then send the file contents to a multi-line TextBox
    txtWebPageTextEditorField.Text = System.IO.File.ReadAllText(Request.MapPath("~/Files/DownloadedFile.txt"))
  End Sub

  Private Sub cmdSave_Click(Sender As Object, e As EventArgs) Handles cmdSave.Click
    ' Save the file after editing
    System.IO.File.WriteAllText(Request.MapPath("~/Files/DownloadedFile.txt"), txtWebPageTextEditorField.Text)

    ' Now use WinSCP to upload your file back to the server you got it from
  End Sub
End Class

This of course assumes you're working with a text file. If it's binary you're going to need special handling.

Jeff Bowman
Fairbanks, Alaska
luismdmauricio
[View user's profile]

Joined: 2015-04-10
Posts: 3
Location: Portugal
Hi Jeff,

Thanks for your help!

My asp.net application is more complicated. I need explicity to use word files and I do not want to use Interop to it because of the security issues in server side.

I've tried your approach using Telerik RadEditor but the documents that will be managed need to use diagrams, texboxes, etc. that will be used to explain the corresponding text paragrahs. So , RadEditor is not sufficent Sad

Thats why I remender the Edit menu option in the WinSCP application.

Best regards
InteXX
[View user's profile]

Joined: 2009-05-17
Posts: 21
Location: Fairbanks, Alaska
You're on the right track, then... my example is intended to demonstrate the concept only. It sounds like you already understand the concept.

In fact this is the way any application would do it, including WinSCP. It downloads the file to a temp folder, opens it with the appropriate editor, saves it, and then uploads it back to the source.

All that's left for you to do now is find an editor for ASP.NET that can work with your file type. That task is beyond the scope of this forum, of course, but you've already got a good head start on the job.

Best of luck to you; signing off now...

Jeff Bowman
Fairbanks, Alaska
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
InteXX wrote:
You're on the right track, then... my example is intended to demonstrate the concept only. It sounds like you already understand the concept.

In fact this is the way any application would do it, including WinSCP. It downloads the file to a temp folder, opens it with the appropriate editor, saves it, and then uploads it back to the source.

All that's left for you to do now is find an editor for ASP.NET that can work with your file type. That task is beyond the scope of this forum, of course, but you've already got a good head start on the job.

Thanks for your response. I just confirm that this is the correct answer!
_________________
Martin Prikryl
InteXX
[View user's profile]

Joined: 2009-05-17
Posts: 21
Location: Fairbanks, Alaska
prikryl wrote:
Thanks for your response.

You're welcome Smile

Thanks,
Jeff Bowman
Fairbanks, Alaska
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License