Guest User

Untitled

a guest
Oct 22nd, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. $('#btnDeleteFiles').click(function () {
  2. var filesPaths = [];
  3. i = 0;
  4. $("input:checkbox[name=filed-checkedbox]:checked").each(function () {
  5. filesPaths[i] = $(this).val();
  6. i++;
  7. });
  8.  
  9. //alert("filesPaths = " + filesPaths)
  10. var location = $('#ddlLocation option:selected').text();
  11. alert("Location = "+location)
  12. $.ajax({
  13. method: 'post',
  14. url: "GetAllFolderDetails.asmx/setDeleteFiles",
  15. data: {
  16. location: location,
  17. fileNames: filesPaths
  18. },
  19.  
  20. dataType: "json",
  21. success: function (data) {
  22. window.location.reload(true);
  23. //alert("Success");
  24.  
  25. },
  26. error: function (result) {
  27. alert("Error");
  28. }
  29. });
  30. });
  31.  
  32. [WebMethod]
  33. public void setDeleteFiles(string location, string[] fileNames)
  34. {
  35.  
  36. var locationID = 0;
  37. var domain = "domain";
  38. var username = "xxx"; //username
  39. var Password = "***"; //password
  40.  
  41. Debug.WriteLine("Location = "+location);
  42. Debug.WriteLine("fileNames = " + fileNames);
  43.  
  44. using (new ImpersonateUser(username , domain, Password))
  45. {
  46. Debug.WriteLine("Files names = "+ fileNames);
  47. foreach (string file in fileNames)
  48. {
  49. FileInfo files = new FileInfo(file);
  50. files.Delete();
  51. }
  52. JavaScriptSerializer js = new JavaScriptSerializer();
  53. Context.Response.Write(js.Serialize("Files are successfully Deleted"));
  54. }
  55. }
Add Comment
Please, Sign In to add comment