I was wondering if they would give me a help, I explain the problem.
I am saving images in an object from an asp.net form but apart from that I must send the image to a folder on my desktop, but the path does not work correctly for me, since my visual studio is installed on the local disk E and where I I want the images to be saved on the desktop, which would be local disk C.
My code works, but only if I create the folder inside the project.
var files = HttpContext.Request.Form.Files;
string webRootPath = _webHostEnvironment.WebRootPath;
string upload = webRootPath + WC.ImagenRuta;
string fileName = Guid.NewGuid().ToString();
string extension = Path.GetExtension(files[0].FileName);
using (var fileStream = new FileStream(Path.Combine(upload, fileName + extension), FileMode.Create))
{
files[0].CopyTo(fileStream);
}
this is the class where i store the path where i want it to be saved
public static class WC
{
//public static string ImagenRuta = @"\imagenes\tours\";
public static string ImagenRuta = @"C:\Users\jason\Desktop\Imagenes";
}
As I mentioned, the first public works fine since it is a route within the project \images\tours\ but the second is the one I want to put to work but it does not work for me.
I enclose a link of the error that appears because it does not let me upload the photo here
https://drive.google.com/file/d/1E-wCuGeYMBF74Pi1MoHuiR1-kGk1SSUH/view?usp=sharing
Replaces:
By:
In this way, your image will be saved in: