I am developing a website link in which I have a page that uploads images to a server of Windows Server type.
The folder where I want the images to be saved is in the same one that the project is located in, that is to say. C:\Users\adminyo\proyectosdevisual\img....
The adminyo
folder is the one that is shared with me to administer since it is not my server and what I want is to paste the images in that place, but I do not know how to give it permission through C # code (it is with what I developed the page) so that it allows me to save files because when I save it comes out
Access to the path 'C: \ Users \ adminyo \ visualprojects \ img ...' is denied.
All this I do in the following way
string filepath = "C:\Users\adminyo\proyectosdevisual\img...;
HttpFileCollection uploadedFiles = Request.Files;
Span1.Text = string.Empty;
for (int i = 0; i < uploadedFiles.Count; i++)
{
HttpPostedFile userPostedFile = uploadedFiles[i];
try
{
if (userPostedFile.ContentLength > 0)
{
Span1.Text += "<u>Imagen #" + (i + 1) + "</u><br>";
Span1.Text += "Tipo de imagen: " + userPostedFile.ContentType + "<br>";
Span1.Text += "Tamaño de imagen: " + userPostedFile.ContentLength + "kb<br>";
Span1.Text += "Nombre de la imagen: " + userPostedFile.FileName + "<br>";
userPostedFile.SaveAs(filepath + "\" + Path.GetFileName(userPostedFile.FileName));
Span1.Text += "Se guardó en: " + filepath + "\" + Path.GetFileName(userPostedFile.FileName) + "<p>";
}
}
catch (Exception Ex)
{
Span1.Text += "Error: <br>" + Ex.Message;
}
}
The folder that has the permissions is adminyo
what I do not want is to move the permissions of it, rather I would like to find a way to access it since I have the credentials, since when I enter the server I do it remotely with my credentials but what I want is to be able to save the images through my application. How to indicate to the server that the application is authorized to save images?