SFTPPermissionDeniedexception while uploading CSV file (rootfolder issue?)

Nov 6, 2015 at 7:23 AM
we cannot upload file to SFTP server. Below is the code:
        SftpClient sftp = null;
        try
        {
            byte[] b = GetBytes(csvFile.CSVFileString);
            int port = 22;
            using (sftp = new SftpClient(ftpInfo.Url, port, ftpInfo.UserName, ftpInfo.Password))
            {
                sftp.Connect();                    
                MemoryStream stream = new MemoryStream(b);
                try
                {        
                    sftp.BufferSize = 4 * 1024;
                    sftp.UploadFile(stream, csvFile.CSVFileName);
                }
                catch (Exception ftpex)
                {
                    throw new Exception("SFTP failure : " + ftpex.Message);
                }                    
                sftp.Disconnect();
            }  
        }
If we add sftp.ChangeDirectory("/Data/test"); it uploads it successfully at "/data/test" folder on SFTP server. Cannot we upload at the root folder? or do we have to configure SFTP server to allow it?