Edit Remote File Using .NET assembly

Advertisement

luismdmauricio
Joined:
Posts:
3
Location:
Portugal

Edit Remote File Using .NET assembly

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

Reply with quote

Advertisement

InteXX
Joined:
Posts:
29
Location:
Fairbanks, Alaska

Re: Edit Remote File Using .NET assembly

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:

https://winscp.net/eng/docs/library#using

Jeff Bowman
Fairbanks, Alaska

Reply with quote

luismdmauricio
Joined:
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

Reply with quote

InteXX
Joined:
Posts:
29
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:

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

Reply with quote

luismdmauricio
Joined:
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 :-(

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

Best regards

Reply with quote

Advertisement

InteXX
Joined:
Posts:
29
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

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,469
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!

Reply with quote

InteXX
Joined:
Posts:
29
Location:
Fairbanks, Alaska

martin wrote:

Thanks for your response.
You're welcome :-)

Thanks,
Jeff Bowman
Fairbanks, Alaska

Reply with quote

Advertisement

You can post new topics in this forum