Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Access to the path is denied
#1
Deleting files using the built-in functions in C# throws an error, but using the LA function deletes them successfully. Why?

System.UnauthorizedAccessException: Access to the path 'C:\Users\Administrator\Desktop\240402_105050.dat' is denied.
   at line 5 in Script2.cs
   >>
   --- Raw stack trace ---
   at System.IO.FileSystem.DeleteFile(String fullPath)
   at Program.<Main>$(String[] args) in C:\Users\Administrator\Documents\LibreAutomate\Main\files\Script2.cs:line 5



Code:
Copy      Help
//.
script.setup(trayIcon: true, sleepExit: true);
//..

File.Delete(@"C:\Users\Administrator\Desktop\240402_105050.dat"); //NO
//filesystem.delete(@"C:\Users\Administrator\Desktop\240402_105050.dat"); //OK
#2
I guess the file has READONLY attribute. LA function removes it before deleting.
#3
Thanks, You are right, LA is very powerful, helping to deal with many detailed issues.


Forum Jump:


Users browsing this thread: 1 Guest(s)