I wrote a .net C# application that writes text files to a unix machine, where an application reads it. My application writes files just fine to the target folder, but the unix application throws an error saying it doesn’t have permission to read the file.
When I send files using WinSCP, I can see the rights are rwxrwxrwx.
when my app sends files the rights are rw-r—–.
I assume this is the reason.
Here is my code:
public override void WriteFile(string directoryName, string fileName, string text) {
sshExec.RunCommand(@"echo """ + text + @""" > " + directoryName + "/" + fileName);
}
How do I set the rights so the other application can read the file?
This is not FTP, this is usage of SSH shell.
You should append something like “& chmod 777 ” + directoryName + “/” + fileName to your command.