after few days of searching and investigating the problem, I finnaly decided to ask the question over here.
In the beginning I want to apologize for my english, it's not so well as it should be, so hope, you'll understand the question well :).
I have a problem when using File.Copy in ASP.NET to summarize the problem - it always says, that I don't have the permission to access the folder defined in "pathFrom". (the only way how the code works is, when I run it in my Visual Studio in debugger), after I upload it on web server, it stops working.
CODE:
protected void buttonclick(object sender, Eventargs e){
string pathFrom = "\\sqlSRV\folder1\thisOne.txt";
string pathTo = "\\webSRV\folder2\overHere.txt";
string directory = "\\sqlSRV\folder2";
if (Directory.Exists(directory))
{
try
{
File.Copy(pathFrom, pathTo, true);
}
catch (FileNotFoundException)
{
Lab0.Text = "Not found.";
}
catch (FileLoadException)
{
Lab0.Text = "Cant open.";
}
}
- The servers are in the same domain.
- Shared folders does have ALL permissions for
sqlSRV$
and webSRV$
, NETWORK SERVICE
, IIS_WPG
even for group Everyone
(just for testing right now)
- we don't want to use impersonate and write the username and password into the code due to security
- everything is on our LAN
- running IIS10
In the old days we had similiar function in ActiveX, where it all worked (because it knew which user was running the code).
Can anyone, please, help?
Thanks a lot
question from:
https://stackoverflow.com/questions/65951942/access-denied-when-using-file-copy 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…