0

How can I save a file to a folder that is protected? How do I add the user and password to my route so I can save a file? For example, C: \ Desktop \ Folder When I try to open the folder, it asks for a username and password, how can I authenticate from the code?

var fullPath = Path.Combine(STORAGE_ROOT, Path.GetFileName(fileInfo.fileId));
file.SaveAs(fullPath);
return fileInfo;

In STORAGE_ROOT, I have saved the path of the folder And in Path.GetFileName (fileInfo.fileId), I have the file.

Marco
  • 22,856
  • 9
  • 75
  • 124
Alba
  • 47
  • 4
  • how was the folder created? – Daniel A. White Oct 03 '18 at 17:53
  • It is a folder created manually by a user in a specific directory. I have to save in that folder. – Alba Oct 03 '18 at 17:57
  • so a standard folder? is the user running the program have permission to it? – Daniel A. White Oct 03 '18 at 17:57
  • The code has explicit a user variable and password with the data to access that folder. I do not know how the code passes those variables to the folder to authenticate In the future you will get the user and password from a database. – Alba Oct 03 '18 at 18:06
  • 1
    Windows only limit access to (local) filesystems by means of file/folder permissions, not by an extra user/password. Neither Windows has any concept of "protected" data, beyond file permissions. How are you getting such a prompt? By using an external program? Or by using a network share? – Alejandro Oct 03 '18 at 18:07
  • It is using a shared network. When I open the folder on my computer it shows me a Windows Security window where user / password is requested. When my code calls the folder, it will ask to authenticate... – Alba Oct 03 '18 at 19:57
  • Access denied to the path \\ channels1 \ datafile – Alba Oct 03 '18 at 20:09
  • Possible duplicate of [How to provide user name and password when connecting to a network share](https://stackoverflow.com/questions/295538/how-to-provide-user-name-and-password-when-connecting-to-a-network-share) – RQDQ Oct 03 '18 at 21:12

0 Answers0