Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $('#btnDeleteFiles').click(function () {
- var filesPaths = [];
- i = 0;
- $("input:checkbox[name=filed-checkedbox]:checked").each(function () {
- filesPaths[i] = $(this).val();
- i++;
- });
- //alert("filesPaths = " + filesPaths)
- var location = $('#ddlLocation option:selected').text();
- alert("Location = "+location)
- $.ajax({
- method: 'post',
- url: "GetAllFolderDetails.asmx/setDeleteFiles",
- data: {
- location: location,
- fileNames: filesPaths
- },
- dataType: "json",
- success: function (data) {
- window.location.reload(true);
- //alert("Success");
- },
- error: function (result) {
- alert("Error");
- }
- });
- });
- [WebMethod]
- public void setDeleteFiles(string location, string[] fileNames)
- {
- var locationID = 0;
- var domain = "domain";
- var username = "xxx"; //username
- var Password = "***"; //password
- Debug.WriteLine("Location = "+location);
- Debug.WriteLine("fileNames = " + fileNames);
- using (new ImpersonateUser(username , domain, Password))
- {
- Debug.WriteLine("Files names = "+ fileNames);
- foreach (string file in fileNames)
- {
- FileInfo files = new FileInfo(file);
- files.Delete();
- }
- JavaScriptSerializer js = new JavaScriptSerializer();
- Context.Response.Write(js.Serialize("Files are successfully Deleted"));
- }
- }
Add Comment
Please, Sign In to add comment