I am using SshNet to update a text file on a Raspberry Pi server, running Raspbian. The server is running vsftpd as the FTP server.
The user modifies some text in the application (which was downloaded using the ReadAllText method) and then clicks save, which should save the edited text in the specified file on the server, using the WriteAllText method.
The problem is that the text somehow gets corrupted by using the WriteAllText method. Here is what I observed:
- If trying to edit somewhere around the middle of the text, it saves the text fine.
- If trying to add text to the end, it works fine.
- If trying to delete text from the end, all hell breaks loose. Example, editing the end of a text file:
Before deleting:
"Kind regards,
Department management"
After deleting everything after "Kind regards," and saving, this is what gets saved:
"Kind regards,
Department management"
- If trying to replace text at the end:
Replacing "Department management" with "Senior management":
"Kind regards,
Senior managementt" [Notice the double t at the end, it was not a typo. For different text, worse things that a double t appear.]
I have managed to work around it by saving the text to a file in the temp path and uploading it using the UploadFile method, which seems to be working fine.
I have attached the adapter I use for this (stripped of the stuff irrelevant to this problem).
The user modifies some text in the application (which was downloaded using the ReadAllText method) and then clicks save, which should save the edited text in the specified file on the server, using the WriteAllText method.
The problem is that the text somehow gets corrupted by using the WriteAllText method. Here is what I observed:
- If trying to edit somewhere around the middle of the text, it saves the text fine.
- If trying to add text to the end, it works fine.
- If trying to delete text from the end, all hell breaks loose. Example, editing the end of a text file:
Before deleting:
"Kind regards,
Department management"
After deleting everything after "Kind regards," and saving, this is what gets saved:
"Kind regards,
Department management"
- If trying to replace text at the end:
Replacing "Department management" with "Senior management":
"Kind regards,
Senior managementt" [Notice the double t at the end, it was not a typo. For different text, worse things that a double t appear.]
I have managed to work around it by saving the text to a file in the temp path and uploading it using the UploadFile method, which seems to be working fine.
I have attached the adapter I use for this (stripped of the stuff irrelevant to this problem).