protected void gvFiles_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e) { if (e.CommandName == "Del") { int index = int.Parse(e.CommandArgument.ToString()); string fileID = ((Label)gvFiles.Rows[index].Cells[2].FindControl("lblFileName")).Text.Replace(" ", "%20"); string filepath = workSpaceDir(lblSelectedFolder.Text.Trim()) + "\\" + ((Label)gvFiles.Rows[index].Cells[2].FindControl("lblFileName")).Text; ArtefactClient arClient = new ArtefactClient(); try { arClient.DeleteFile(NUSNetUser(), EventID(), lblSelectedFolder.Text.Trim(), fileID); if (filepath.Contains("\\WorkSpace\\")) { if (System.IO.File.Exists(filepath)) { System.IO.File.Delete(filepath); } } lblMsg.Text = "File Successfully removed!"; loadFiles(lblSelectedFolder.Text.Trim()); } catch (Exception ex) { Alert.Show(ex.ToString()); lblMsg.Text = "File Failed to remove!"; } finally { arClient.Close(); } //loadFiles(classId, folderID); } }
protected void gvFiles_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e) { if (e.CommandName == "Del") { int index = int.Parse(e.CommandArgument.ToString()); string fileID = ((Label)gvFiles.Rows[index].Cells[2].FindControl("lblFileName")).Text.Replace(" ", "%20"); string filepath = workSpaceDir(lblSelectedFolder.Text.Trim()) + "\\" + ((Label)gvFiles.Rows[index].Cells[2].FindControl("lblFileName")).Text; ArtefactClient arClient = new ArtefactClient(); try { WorkspaceFiles wrkFile = arClient.GetWorkSpaceFile(NUSNetUser(), EventID(), lblSelectedFolder.Text.Trim(), fileID); if (wrkFile.UploadedBy == NUSNetUser().UserID) { arClient.DeleteFile(NUSNetUser(), EventID(), lblSelectedFolder.Text.Trim(), fileID); if (filepath.Contains("\\WorkSpace\\")) { if (System.IO.File.Exists(filepath)) { System.IO.File.Delete(filepath); } } lblMsg.Text = "File Successfully removed!"; txtFileDesc.Text = ""; txtFileURLExt.Text = ""; loadFiles(lblSelectedFolder.Text.Trim()); } else { lblMsg.Text = "You can only delete what is belong to you!"; } } catch (Exception) { lblMsg.Text = "File Failed to remove!"; } finally { arClient.Close(); } //loadFiles(classId, folderID); } }