I have an application in C # that downloads certain files from an API using RestSharp, I do not have problems when downloading them in the root of the project, but if for example I try to download them in the path C: / ProjectName / file.txt I have an error of this type:
Excepción no controlada del tipo 'System.IO.DirectoryNotFoundException' en
mscorlib.dll
No se puede encontrar una parte de la ruta de acceso 'C:\Directorio\name.txt'.
When I tell him to save in this way he gives me an error:
client.DownloadData(request).SaveAs(@"C:/Directorio/"+id+"-name" + ".txt");
But when I leave it without a path, it saves well in the root directory:
client.DownloadData(request).SaveAs(id + "-name" + ".txt");
How should I tell you to save in C or My Documents?