I want to copy a file from a server to client,i have already connected the server and i can add some content in a particular file in the server. I have gone through this tutorials and this ,hence i wrote some codes based on the tutorials. but its not working. I knew that there is some error while getting the destination path.while debugging i got this error Unhandled exception thrown: read access violation. file was nullptr... and i found 'The error is in fd (sftp_file fd;), i assigned the path (client) "C:/Users/Sami/Desktop/" where i want to copy the wi.exe from "/home/server/Desktop/sa/wi.exe" this path (server).' How can i correct this?
access_type = O_RDONLY;
file = sftp_open(sftp, "/home/server/Desktop/sa/wi.exe",access_type,0);
fd = sftp_open(sftp,"C:/Users/Sami/Desktop/", O_CREAT, 0);
nbytes = sftp_read(file, buffer, sizeof(buffer));
nwritten = sftp_write(fd, buffer, nbytes);
sftp_close(file);